COMCSS page# 0001 next
2: COMMENT ⊗   VALID 00113 PAGES
3: C REC  PAGE   DESCRIPTION
4: C00001 00001
5: C00012 00002    BEGIN APRSER ↔ SUBTTL   SAVGET  4 AUG 67
6: C00014 00003    ROUTINE TO SCAN COMMAND STRING ARGUMENTS FOR SAVE,GET,RUN AND R
7: C00019 00004    THIS JOB SAVES A JOB AREA ON RETRIEVABLE STORAGE
8: C00021 00005    THIS JOB GETS A JOB AREA FROM A RETRIEVABLE DEVICE
9: C00023 00006    JOB HAS JUST A JOB DATA AREA ASSIGNED WHEN CONTROL GETS HERE
10: C00025 00007    ROUTINE TO SETUP ACS,RESET IO,ASSIGN DEVICE, AND DO LOOKUP
11: C00027 00008     COMMON SAVEGET ROUTINE, OPEN FILE, DO LOOKUP (ENTER?)
12: C00029 00009     COME HERE ON SAVE DEVICE NOT AVAILABLE
13: C00030 00010    ROUTINE TO SET DUMP MODE COMMAND LIST IN USER AREA
14: C00033 00011    ROUTINE TO RELEASE DEVICE AND FIND TTY
15: C00034 00012    ROUTINE TO GET FILE FROM DEVICE
16: C00037 00013    HERE WE DISCOVER IF WE HAVE A HIGH SEGMENT TO SET-UP
17: C00039 00014    END OF GET, REMAP ERROR, SETPR2 KLUDGE
18: C00042 00015     ROUTINE TO STUFF A FILE ON A DEVICE
19: C00045 00016     SAVE ROUTINE
20: C00047 00017    BEGIN SEGCSS ↔ SUBTTL   SEGCSS  8 SEPT 69       JAM
21: C00049 00018     ROUTINE TO INVENT AN UPPER SEGMENT
22: C00051 00019     THIS ROUTINE DEFINES A SEGMENT. IT SEARCHES FOR AN EXISTING
23: C00055 00020     ROUTINE TO KILL A HIGH SEGMENT
24: C00058 00021     ROUTINE TO ERASE A SEGMENT ENTIRELY
25: C00060 00022     ROUTINE TO FLUSH A JOB'S HIGH SEGMENT AND ALL THE SEGMENTS HE MAY HAVE
26: C00064 00023     UAPPLY - APPLY A ROUTINE TO ALL LOWERS OF AN UPPER.
27: C00066 00024    SUBTTL  COMCSS  4 AUG 67
28: C00067 00025    CTEX0:  PUSHJ PDP,GETLCCHR
29: C00069 00026    ROUTINE TO IGNORE LEADING SPACES, TABS, AND NULLS
30: C00071 00027    ROUTINE TO APPEND A "?" TO INPUT STRING AND SET AS OUTPUT
31: C00074 00028    ROUTINE TO PRINT A COMMAND ERROR MESSAGE
32: C00076 00029    ROUTINE TO PRINT INLINE ASCIZ MESSAGE - INLMES, PRCRCC, PRCNCC
33: C00078 00030    ROUTINE TO DEASSIGN A DEVICE
34: C00080 00031    ROUTINE TO READ CONSOLE AND CONVERT ANY RADIX NUMBER
35: C00083 00032    GET PROJECT-PROGRAMMER NUMBERS
36: C00085 00033    ROUTINE TO PRINT TIME AS HOURS,MINUTES,SECONDS, AND HUNDRETHS
37: C00087 00034    SUBTTL  ERRCON  4 AUG 67
38: C00089 00035    APRNXM: TRNN TAC,NXM            NON-EX MEM?
39: C00090 00036     ROUTINE TO PRINT ERROR MESSAGE FOR SPW MODULES
40: C00092 00037    ADDRESS CHECK ERROR AT ANY LEVEL
41: C00093 00038    CALL:   JSP DAT,ERROR
42: C00094 00039     UERROR IS FOR UUO LEVEL, BLAMES CURRENT JOB
43: C00095 00040     USER TRIED TO GIVE LPT OR PTP A BUFFER LARGER THAN
44: C00097 00041    UUOERR: ILLEGAL UUO 
45: C00100 00042    ILLEGAL INSTRUCTION  -  ILLINS, HALT
46: C00102 00043    ROUTINE FOR HUNG IO DEVICE
47: C00104 00044    ROUTINE TO HALT A JOB WHEN A DEVICE IS NOT READY FOR I/O
48: C00105 00045     ROUTINE TO PRINT A MESSAGE AND STOP A JOB IN A WAY
49: C00106 00046    COMMON ERROR MESSAGE SETUP ROUTINES - ERRPTU
50: C00109 00047    ROUTINE TO PRINT UUO PC AND STOP JOB - UUOMES, UUOPCP, PCPNT
51: C00111 00048    ROUTINE TO PRINT EITHER: - PCSTOP, PCP
52: C00113 00049    ROUTINE TO PRINT 36 BIT OCTAL NO
53: C00114 00050    ROUTINE TO PRINT "DEVICE XXX"
54: C00115 00051     ROUTINE TO TYPE OUT DISASTER BUFFER ON CTY AT CLOCK LEVEL
55: C00117 00052     ROUTINE TO CALL WITH PIS OFF TO FINISH FLUSHING
56: C00119 00053     THIS ROUTINE TYPES ONE CHARACTER IN TEM THROUGH
57: C00121 00054    DISMES, DISCRLF, DISTAB, DISJOB
58: C00123 00055    CALLING SEQUENCE
59: C00124 00056     HERE ARE THE VARIOUS PRINTOUT ROUTINES FOR DISERR
60: C00125 00057    DISLOC PRINTS OUT 6 DIGIT OCTAL LOCATION WITHOUT LEADING ZEROES
61: C00128 00058     SIXBIT PRINT ROUTINE FOR DISASTER MESSAGES
62: C00129 00059     INITIALIZE ROUTINE FOR DISASTER MESSAGES . . .
63: C00130 00060     ROUTINE TO TYPE ON THE CTY WITH PIS OFF
64: C00132 00061     ROUTINE TO SHOVE THE TIME AND DATE INTO THE BUFFER
65: C00134 00062    SUBTTL  IOCSS   4 AUG 67
66: C00137 00063     ROUTINE TO PUSH CURRENT PR ON STACK AND SET UP NEW PR
67: C00138 00064     ROUTINE TO ADDRESS CHECK SOMETHING
68: C00140 00065    ROUTINE TO ADVANCE INPUT BUFFER AT INTERRUPT LEVEL
69: C00143 00066    ROUTINE TO ADDRESS CHECK AT UUO LEVEL ONLY
70: C00144 00067    ROUTINE TO ADDRESS CHECK AT UUO LEVEL ONLY
71: C00146 00068    ROUTINE TO ADDRESS CHECK AT ANY LEVEL
72: C00147 00069    ROUTINE TO CHECK VALIDITY OF A DUMP MODE COMMAND LIST
73: C00149 00070    COMCK1: SOJLE ITEM,COMCKE       EXCEEDED 100 YET?
74: C00151 00071    ASSASG  ASSIGN DEVICE IF UNASSIGNED
75: C00154 00072    ROUTINE TO SEARCH FOR A DEVICE
76: C00156 00073    SEARCH PHYSICAL NAMES
77: C00158 00074    ROUTINE TO SETUP N-RING IO BUFFER IN USER AREA
78: C00161 00075     HERE, WE WANT TO EXPAND CORE TO FIT IN A RING OF BUFFERS
79: C00163 00076     END OF LOOP FOR SETTING UP AN N-RING BUFFER
80: C00165 00077    ROUTINE TO CLEAR IO BUFFER IN USER AREA
81: C00167 00078    ROUTINE TO COMPUTE 12 BIT FOLDED CHECKSUM
82: C00169 00079    ROUTINE TO CLEAR RESIDUE OF WORD POINTED TO BY A BYTE POINTER
83: C00170 00080    IOALL, IOALLR, IORELS,IOWAIT
84: C00175 00081    IOKILL, CLRUSR
85: C00177 00082    ROUTINE TO FLAG DEVICE ACTIVE  - ORACT, SETACT, CLRACT, STOIOS
86: C00178 00083     THIS ROUTINE UPDATES EACH DEVICE'S HUNG COUNT AND DISPATCHES
87: C00180 00084     OTHER USEFUL ROUTINES FOR SETING UP USER BUFFER POINTERS
88: C00181 00085     SET UP WORD COUNT IN AC2
89: C00182 00086    ROUTINE TO SETUP PROG AND ITEM FOR INTERRUPT SERVICE ROUTINE
90: C00183 00087    CALLING SEQUENCE
91: C00185 00088    ROUTINE TO RETURN NO. OF ITEMS IN BUFFER
92: C00186 00089    ROUTINE TO SET DEVICE STATUS WORD FROM UUO
93: C00187 00090    SETUP BYTE POINTER AND ITEM COUNT
94: C00188 00091    ROUTINE TO SETUP BYTE POINTER ACCORDING TO DATA MODE
95: C00189 00092     ROUTINE TO STORE DATA IN IOBUFFER FOR INPUT DEVICES THAT
96: C00191 00093    ↑STODAT:
97: C00193 00094    ↑STOSQD:
98: C00195 00095    RUNCSS  4 AUG 67 - KSTOP
99: C00198 00096    ROUTINE TO STOP JOB, SET ERROR BIT AND PRINT MESSAGE - HOLD, PHOLD
100: C00199 00097    ROUTINE TO STOP USER AND FLAG AS ERROR STOP - ESTOP, MSTOP
101: C00204 00098    ROUTINE TO STOP ANY JOB FROM BEING SCHEDULED - STOP1, SETSTP
102: C00207 00099    DLYCOM     ROUTINE TO REQUE JOB WHICH HAS HAD A COMMAND TYPED
103: C00208 00100    ROUTINE TO PUT JOB IN NO CORE QUEUE
104: C00209 00101    ROUTINE TO SETUP MONITOR JOB TO RUN LATER AT UUO LEVEL - MONJOB
105: C00210 00102    MONSTR ROUTINE TO SETUP ACS FOR MONITOR JOB STARTING AT UUO LEVEL
106: C00212 00103    ROUTINE TO SET JOB STATE TO BE SCHEDULED TO RUN - USTART, MSTART
107: C00216 00104    ROUTINE TO SET JOB STATUS RUN BIT(RUN)
108: C00218 00105    ROUTINE TO PUT A JOB TO SLEEP AND WAKE UP AGAIN LATER
109: C00220 00106    ROUTINE TO GET DATA CONTROL AND ANOTHER SHARABLE DEVICE
110: C00222 00107    ROUTINE TO WAIT FOR A SHARABLE DEVICE
111: C00224 00108    SETIOD - ROUTINE TO SET JOB TO RUN AFTER IT HAS BEEN STOPPED
112: C00226 00109    ROUTINE TO CAUSE CLK ROUTINE TO RESCHEDULE - WSCHED
113: C00228 00110    ROUTINE TO WAIT TILL DEVICE CATCHES UP WITH USER AND BECOMES INACTIVE
114: C00230 00111    WSYNC IS CALLED TO WAIT UNTIL 
115: C00232 00112     WE GET HERE IF THIS DEVICE HAS CONTROL CELLS
116: C00234 00113    REPEAT 0,<
117: C00235 ENDMK
118: C⊗;
    COMCSS page# 0002 next  prev
120: BEGIN APRSERSUBTTL   SAVGET  4 AUG 67
121: 
122: ;SPECIAL LOCATION IN USER JOB DATA AREA FOR STORING ARGUMENTS
123: ;USED IN UUO CALLS TO THE MONITOR
124: 
125: ;FOR LOOKUP UUO
126: FILNAM←←0               ;FILE NAME
127: FILEXT←←FILNAM+1        ;FILE EXTENSION
128: FILDAT←←FILNAM+2        ;DATE WRITTEN
129: FILLEN←←FILNAM+3        ;LH=-LENGTH,RH=FIRST LOC-1 DUMPED ON ENTER
130:                         ;PROJECT PROGRAMMER ON LOOKUP
131: 
132: DMPEND←←FILLEN+1        ;LAST WORD OF DUMP COMMAND LIST=0
133: 
134: ;FOR OPEN UUO
135: MODWRD←←5               ;IOS MODE WORD FOR OPEN UUO
136: DEVWRD←←MODWRD+1        ;DEVICE NAME
137: HEDWRD←←MODWRD+2        ;INPUT AND OUTPUT BUFFER HEADER ADDRESSES
138: 
139: 
140: DMPWRD←←11      ;DUMP WORD FOR SAVE COMMAND
141: NEWCOR←←12      ;NEW CORE ASSIGNMENT FOR RUN AS SPECIFIED BY THIRD
142:                 ;ARGUMENT TO PREVIOUS SAVE.
143: INCWRD←←13     ;STARTING INCREMENT STORAGE FOR MONITOR JOB.
144: 
145: COMWRD←←17      ;TO PASS COMMAND TO PROG
146: CHRWRD←←16      ;DITTO DELIMITER
    COMCSS page# 0003 next  prev
148: ;ROUTINE TO SCAN COMMAND STRING ARGUMENTS FOR SAVE,GET,RUN AND R
149: ;COMMANDS AND STORE THEM IN JOB DATA AREA WHICH MUST BE IN CORE
150: ;WHEN SGSET IS CALLED FROM COMMAND DECODER
151: ;CALL:  MOVE TAC,INPUT BYTE POINTER
152: ;       MOVE TAC1,SIXBIT DEVICE NAME
153: ;       MOVE DAT,OUTPUT BYTE POINTER
154: ;       MOVE IOS,ADR. OF MONITOR JOB(SAVJOB,GETJOB,RUNJOB)
155: ;       MOVE PROG, ADR. OF JOB AREA
156: ;       PUSHJ P,SGSET
157: 
158: ;SET AC2 TO EXPLICIT PPN OF FILE AND ENTER BY:  PUSHJ P,SGSET0
159: 
160: C←←BUFPNT
161: 
162: SGDVOK: PUSH    P,TAC                   ;CHECK TO SEE IF ARG IS LEGAL SAVEGET DEV
163:         PUSH    P,IOS
164:         PUSH    P,DAT
165:         PUSH    P,DDB
166:         MOVE    TAC,TAC1
167:         PUSHJ   P,DEVSRC                ;IS THERE SUCH A DEVICE
168:         JRST    SGSETB                  ;NOT A LEGAL DEVICE. ASSUME IT WAS FILENAME
169:         MOVE    TAC,DEVMOD(DDB)
170:         TLNE    TAC,DVDSK!DVDTA!DVMTA   ;ONLY LEGAL DEVICES FOR SAVE GET
171:         AOS     -4(P)
172: SGSETB: POP     P,DDB
173:         POP     P,DAT
174:         POP     P,IOS
175:         JRST    TPOPJ
176: 
177: SGSET:  MOVEI   AC2,0                   ;NORMAL ENTRY - DISABLE PPN KLUDGE
178: SGSET0:                                 ;THIS IS THE RUN FROM ANOTHER AREA KLUDGE
179: IFN FTLOGIN,<   MOVEM   AC2,JOBPPN(J)>
180:         MOVEM   TAC1,DEVWRD(PROG)       ;STORE FIRST ARG. MAY BE DEVICE, OR FILE
181:         JUMPE   TAC1,SGSETC             ;ASSUME DSK IF NO ARG
182:         PUSHJ   P,SGDVOK                ;SEE IF IT'S A VALID DEVICE NAME
183:         JRST    SGSETC                  ;WASN'T A DEVICE NAME
184:         SKIPN   TAC1,JOBNAM(J)          ;WAS DEVICE.   AUTOMATIC FILENAME?
185:         JRST    SGSET3                  ;NO. READ ONE FROM THE COMMAND STRING
186: SGSETA: MOVEM   TAC1,FILNAM(PROG)       ;OK. SET FILE NAME
187:         MOVSI   TAC1,'DMP'
188:         MOVEM   TAC1,FILEXT(PROG)       ;DEFAULT EXTENSION
189: IFN FTLOGIN,<   SETZM   FILLEN(PROG)
190:                 XCT     SGPPN   >       ;LOAD AC1 WITH DEFAULT PPN
191:         JRST    SGSET1
192: 
193: SGSETC: MOVSI   TAC1,'DSK'              ;NO TRY TO ASSUME DISK
194:         EXCH    TAC1,DEVWRD(PROG)       ;USE THIS FOR FILENAME
195:         JUMPN   TAC1,SGSETD
196:         SKIPN   TAC1,JOBNAM(J)
197:         JRST    NOTENF
198:         JRST    SGSETA
199: 
200: SGSET3: PUSHJ   P, CTEXT1               ;GET FILE NAME FROM COMMAND STRING
201:         JUMPE   TAC1,NOTENF             ;THERE MUST BE A FILE NAME
202: SGSETD: MOVEM   TAC1,FILNAM(PROG)       ;STORE FILE NAME
203:         MOVEM   TAC1,JOBNAM(J)          ;STORE ALSO FOR SYSTAT
204: IFN FTSTAT,<    PUSHJ   P,NAMSTT>
205:         MOVSI   TAC1,'DMP'              ;ASSUME EXTENSION
206:         CAIN    TEM,"."                 ;EXTENSION EXPECTED?
207:         PUSHJ   P,CTEXT1                ;YES. GET EXTENSION, OTHERWISE USE DEFAULT
208:         HLLZM   TAC1,FILEXT(PROG)       ;STORE IT FOR LOOKUP
209: 
210: IFN FTLOGIN,<
211:         SETZM   FILLEN(PROG)
212:         PUSHJ   P,PJPGNO                ;GET PROJ. PROG. NO.
213: SGPPN:                                  ;THIS IS A SUBROUTINE CALLED BY XCT SGPPN
214: IFE FTDSKPPN,<  MOVE    AC2,PRJPRG(J)>
215: IFN FTDSKPPN,<  JSP     AC1,[SKIPN AC2,DSKPPN(J)
216:                         MOVE AC2,PRJPRG(J)
217:                         JRST (AC1)]     >;FTDSKPPN
218: >;FTLOGIN
219: 
220:         PUSHJ   P,DECIN1        ;AMOUNT OF CORE (OPTIONAL THIRD ARG.)
221:         JRST    SGSET1          ;DOES NOT RETURN IF ERROR, RETURN HERE IF NO ARG.
222:         JRST    COMERA          ;ILLEGAL CHARACTER
223:         LSH     TAC1,12         ;CONVERT TO HIGHEST REL. LOC.
224:         SUBI    TAC1,1
225: SGSET1: HRRZM   TAC1,JOBCOR(PROG)       ;STORE FOR RUN COMMAND AND SAVE
226: IFN FTLOGIN,<   SKIPN   JOBPPN(J)       ;SKIP IF EXPLICIT PPN KLUDGE.
227:                 MOVEM   AC2,JOBPPN(J)>  ;SAVE PPN
228:         MOVE    TAC1,IOS                ;SCHEDULE MONITOR JOB
229:         JRST    MSTART                  ;START JOB WITH PC IN MONITOR MODE
    COMCSS page# 0004 next  prev
231: ;THIS JOB SAVES A JOB AREA ON RETRIEVABLE STORAGE
232: ;THIS JOB RUNS IN EXEC. MODE AND CALLS IO ROUTINES DIRECTLY
233: ;NO ATTEMPT IS MADE TO SAVE STATUS OF IO DEVICES, JOBPDP, OR AC'S
234: ;IN FACT THE ONLY USEFUL THING WHICH MAY BE DONE WITH A JOB AREA
235: ;AFTER IT HAS BEEN SAVED IS TO START EXECUTION OVER AT THE STARTING
236: ;ADDRESS
237: 
238: 
239: SSAVJB:
240:         JSP TAC1,SG1            ;SET UP FOR SAVE
241:         JFCL
242:         PUSHJ P,SSAVJA          ;NON-FLUSH SEGMENT ENTRANCE
243:         JRST SAVJB1
244: 
245: SAVJOB:
246:         JSP TAC1,SG1            ; SET UP ACS AND ASSIGN DEVICE AND LOOKUP
247:         JFCL                    ;FILE DOES NOT ALREADY EXIST RETURN
248:         PUSHJ PDP,SAVJB         ; THIS ROUTINE ACTUALLY DOES THE WORK
249: SAVJB1: PUSHJ P,INLMES
250:         ASCIZ/JOB SAVED IN /
251:         HLRO TAC,FILLEN(PROG)
252:         MOVNS TAC
253:         ADDI TAC,JOBSAV
254:         LSH TAC,-12
255:         ADDI TAC,1
256:         PUSHJ P,RADX10          ;TELL HIM HOW MUCH WE SAVED IT IN
257:         SKIPE NEWCOR(JDAT)
258:         JRST SAVEUP             ;AND UPPER
259:         LDB TAC,PSEGN
260:         JUMPE TAC,SAVNUP        ;ANY UPPER AT ALL?
261:         JSP TAC,PHOLD           ;YES, TELL HIM NOT SAVED
262:         ASCIZ/K
263: UPPER NOT SAVED!
264: /
265: 
266: SAVEUP: PUSHJ P,INLMES
267:         ASCIZ/K
268: UPPER SAVED IN /
269:         HLRO TAC,NEWCOR(JDAT)
270:         MOVNS TAC
271:         ADDI TAC,1777
272:         LSH TAC,-12
273:         PUSHJ P,RADX10
274: SAVNUP: JSP TAC,PHOLD
275:         ASCIZ/K
276: /
    COMCSS page# 0005 next  prev
278: ;THIS JOB GETS A JOB AREA FROM A RETRIEVABLE DEVICE
279: ;THIS JOB RUNS IN EXEC. MODE AND CALLS IO ROUTINES DIRECTLY
280: ;NO ATTEMPT IS MADE TO RESTORE STATUS OF IO DEVICES, PC, OR AC'S
281: ;JOBPC IS SET TO STARTING ADDRESS OF JOB
282: ;CORE MUST ALREADY HAVE BEEN ASSIGNED AND THE FOLLOWING LOC. SETUP IN
283: ;JOB DATA AREA:
284: ;JOBPDP, JOBREL
285: 
286: 
287: GETJOB:
288:         JSP TAC1,SG1            ; SET UP ACS AND ASSIGN DEVICE AND DO LOOKUP
289:         JRST NOFILE             ;FILE NOT FOUND RETURN
290:         PUSHJ PDP,GETJB         ;GET THE JOB
291: GETJ1:  PUSHJ P,INLMES          ;RETURN ONLY IF EVERYTING OK
292:         ASCIZ /JOB SETUP IN /
293:         HLRZ TAC,JBTADR(J)
294:         LSH TAC,-12
295:         ADDI TAC,1
296:         PUSHJ P,RADX10
297:         LDB AC3,PSEGN
298:         JUMPE AC3,GETNUP
299:         PUSH P,AC3
300:         PUSHJ P,INLMES
301:         ASCIZ/K
302: YOUR UPPER IS /
303:         POP P,AC3
304:         HLRZ TAC,JBTADR(AC3)
305:         ADDI TAC,1777
306:         LSH TAC,-12
307:         PUSHJ P,RADX10
308: GETNUP: JSP TAC,PHOLD
309:         ASCIZ/K
310: /
311: NOFILE: PUSHJ P,CLRTPV          ;NOT FOUND--CLEAR TEMPORARY PRIVILEGES
312:         PUSHJ PDP,SGREL         ;RELEASE DEVICE, FIND TTY
313:         PUSHJ PDP,PRQM
314:         PUSHJ PDP,CRLF
315:         MOVE TAC1,FILNAM(PROG)  ;PRINT FILE NAME
316:         PUSHJ PDP,PRNAME
317:         PUSHJ PDP,PRPER         ;PRINT PERIOD
318:         HLLZ TAC1,FILEXT(PROG)
319:         PUSHJ PDP,PRNAME        ;PRINT EXTENSION
320:         JSP TAC,PHOLD           ;PRINT MESS. AND STOP JOB
321:         ASCIZ / NOT FOUND/
    COMCSS page# 0006 next  prev
323: ;JOB HAS JUST A JOB DATA AREA ASSIGNED WHEN CONTROL GETS HERE
324: ;THIS MONITOR JOB GETS A JOB AREA FROM A RETRIEVABLE DEVICE
325: ;ASSIGNS CORE AND START
326: 
327: 
328: RUNJOB:
329:         JSP TAC1,SG1            ; SETUP ACS, ASSIGN DEVICE, AND DO LOOKUP
330:         JRST NOFILE             ;NO FILE FOUND RETURN
331:         PUSHJ P,GETJB           ;GET THE FILE
332:         HRRZ TAC,JOBSA(JDAT)    ;GET STARTING ADDRESS
333:         TRNN TAC,-1
334:         JRST NOSTRT
335:         ADD TAC,SAVSAI(J)       ;ADD STARTING ADDRESS INCREMENT
336:         HRLI TAC,USRMOD         ;SET USER MODE BIT
337:         MOVEM TAC,UUOPC(J)      ;MAKE IT LOOK LIKE UUO RETURN
338:         MOVE TAC,JOBPPN(J)      ;GET PRJPRG OF FILE
339:         MOVEM TAC,DMPEND(PROG)  ;GIVE IT TO THE USER
340:         JRST USRXIT             ;AND GO START USER
341: 
342: NOSTRT: PUSHJ P,INLMES
343:         ASCIZ /NO STARTING ADDRESS.
344: /
345:         JRST GETJ1
    COMCSS page# 0007 next  prev
347: ;ROUTINE TO SETUP ACS,RESET IO,ASSIGN DEVICE, AND DO LOOKUP
348: ;CALL:  JSP TAC1,SG1
349: ;       FILE NOT FOUND RETURN
350: ;       FILE FOUND RETURN
351: ;       IOWD FOR THIS SIZE CORE RETURNED IN AC TAC
352: ;       DEVMOD IN TAC1
353: 
354: 
355: 
356: SG1:    JSP TAC,MONSTR          ;SETUP PROG,PDP,RESET DEVICES
357:                                 ;PUT TAC1 ON END OF PD LIST
358:         PUSHJ PDP,RESETUUO      ;RELEASE ALL DEVICES
359:         MOVEI TAC,2             ;SAVE MODE
360:         MOVEM TAC,MODWRD(PROG)  ;STORE FOR OPEN UUO
361:         SETZM HEDWRD(PROG)      ;CLEAR BUFFER HEADER ARG.
362:         SKIPN TAC,JOBCOR(PROG)  ;WAS CORE SIZE SPECIFIED
363:         JRST SGCOR              ;NO
364:         CAMG TAC,USRREL(PID)    ;YES, MUST WE GET SOME MORE
365:         JRST SGCOR1             ;NO
366:         PUSHJ P,RUNCOR          ;TRY FOR ENOUGH
367:         JRST SG2                ;CAN'T GET IT, GIVE HIM UP TO USRREL
368: SGCOR1: MOVN TAC,JOBCOR(PROG)
369:         JRST SGCOR2
370: 
371: SGCOR:  HRRZ TAC,JOBFF(JDAT)    ; PICK UP FIRST FREE LOCATION
372:         CAMLE TAC,USRREL(PID)   ; IS IT IN BOUNDS?
373:         JRST SG2                ; NO, USE HIGHEST RELOCATABLE ADDRESS
374:         JUMPE TAC,SG2           ; ZERO IS PRETTY SILLY TOO
375:         MOVNS TAC               ; NEGATE TO FORM HALF OF IOWD
376:         SKIPE USRDDT(PID)       ; IF DDT IS IN, SAVE UP TO JOBREL
377: SG2:    MOVN TAC,USRREL(PID)    ;YES, DUMP ALL OF CORE INSTEAD
378: SGCOR2: ADDI TAC,JOBSAV         ;LOWER CORE NOT DUMPED
379:         HRLI TAC,JOBSAV
380:         MOVSM TAC,DMPWRD(PROG)  ;STORE IOWD WORD OF THIS SIZE CORE
    COMCSS page# 0008 next  prev
382: ; COMMON SAVEGET ROUTINE, OPEN FILE, DO LOOKUP (ENTER?)
383: 
384:         OPEN 0,MODWRD           ;TRY TO ASSIGN DEVICE
385:         JRST SGERRA             ;NOT AVAILABLE
386:         MOVE TAC1,DEVNAM(DEVDAT)
387:         MOVEM TAC1,JOBDEV(ITEM)
388:         MOVE TAC1,DEVLOG(DEVDAT)
389:         MOVEM TAC1,JOBLOG(ITEM)
390:         MOVE TAC1,DEVMOD(DEVDAT)
391:         HLRZ TAC,FILEXT(PROG)   ;CHECK FOR DMP
392:         CAIN TAC,'DMP'
393:         TLNN TAC1,DVDTA         ;IS IT ON DTA?
394:         JRST .+2
395:         MOVEI TAC,SAVDMP        ;YES. CHANGE TO "SAV" IF WE HAVE
396:         HRLM TAC,FILEXT(PROG)   ;"RECLAIMING FORMAT" DECTAPES
397:         MOVE AC1,JOBPPN(ITEM)   ; GET PROJECT-PROGRAMMER NUMBER
398:         MOVEM AC1,FILLEN(PROG)  ; SET IT INTO PLACE
399:         TLNN TAC1,DVDSK         ; IS THIS A DISK?
400:         MOVEM TAC,FILLEN(PROG)  ; NO, STORE WORD COUNT
401:         LOOKUP 0,FILNAM         ;LOOKUP FILE NAME
402:         SOS (PDP)               ;NOT FOUND
403:         MOVE TAC,DMPWRD(PROG)   ;FOUND, RETURN IOWD FOR THIS SIZE CORE
404:         MOVE TAC1,DEVMOD(DEVDAT)
405:         MOVE ITEM,JOB(PID)      ; RESTORE JOB NUMBER FOR THOSE WHO NEED IT
406:         TLNE TAC1,DVDSK
407:         JRST SG3
408:         SETZM JOBPPN(ITEM)
409:         JRST CPOPJ1
410: SG3:    MOVE AC1,FILPPN(DEVDAT)
411:         EXCH AC1,JOBPPN(ITEM)
412:         JRST CPOPJ1             ;SKIP RETURN, UNLESS FILE NOT FOUND
    COMCSS page# 0009 next  prev
414: ; COME HERE ON SAVE DEVICE NOT AVAILABLE
415: ; PRINT ERROR MESSAGE AND STOP JOB
416: 
417: SGERRA: JUMPE DEVDAT,SGERR1
418:         MOVEM DEVDAT,(PDP)      ; PRINT DEVICE XXX
419:         PUSHJ PDP,TTYFNU        ; FIND TTY
420:         PUSHJ PDP,PRQM
421:         PUSHJ PDP,CRLF
422:         PUSHJ PDP,ERNAM 
423:         JSP TAC,PHOLD           ;PRINT AND STOP JOB
424:         ASCIZ / NOT AVAILABLE/
425: 
426: SGERR1: PUSHJ PDP,TTYFNU
427:         JSP     TAC,PHOLD
428:         ASCIZ   /?
429: NO SUCH DEVICE/
    COMCSS page# 0010 next  prev
431: ;ROUTINE TO SET DUMP MODE COMMAND LIST IN USER AREA
432: ;AND CHECK TO SEE IF ROOM IN CORE
433: ;THEN EXECUTE INPUT OR OUTPUT UUO,RELEASE DEVICE AND CHECK FOR
434: ;ERRORS
435: ;CALL:  PUSHJ PDP,SGDO
436: ;       INPUT 0,FILLEN OR OUTPUT 0,FILLEN
437: ;       OK RETURN(NO ERRORS)
438: 
439: 
440: 
441: SGDO:   SETZM DMPEND(PROG)              ;SET 2ND WORD OF DUMP LIST TO 0
442:         HLRO TAC,FILLEN(PROG)           ;GET - NO. WORDS TO READ OR WRITE
443:         SUBI TAC,JOBSAV                 ;NO. OF LOWER CORE LOC. NOT DUMPED
444:         ADD TAC,USRREL(PID)             ;HIGHEST LOC. IN USER AREA
445:         JUMPL TAC,NOROOM                ;WILL IT FIT?
446:         MOVEM DEVDAT,USRHCU(PID)        ;SET HIGHEST IO CHAN IN USE NEGATIVE
447:                                         ;ALSO ADDRESS OF SAVE GET DEVICE.
448:         XCT @(PDP)                      ;EXECUTE INPUT OR OUTPUT UUO
449:                                         ;READ INTO PROTECTED PART OF JOB DATA AREA
450:         PUSHJ PDP,CLRUSR                ;CLEAR OUT POSSIBLE GARBAGE
451:                                         ;AND SET USRHCU BACK TO 0
452:         MOVEM DEVDAT,USRJDA(PID)        ;RESTORE CHANNEL 0 ASSIGNMENT
453:         PUSH P,IOS                      ;SAVE POSSIBLE ERROR BITS
454:         PUSHJ PDP,SGREL                 ;RELEASE DEVICE,FIND TTY
455:         MOVE TAC,JOBS41(JDAT)           ;RESTORE USER UUO JSR LOC.
456:         MOVEM TAC,JOB41(JDAT)           ;IN CASE THIS IS GET OR RUN
457:         POP P,TAC                       ;GET BACK BITS
458:         TRNN TAC,IOBKTL+IODERR+IODTER+IOIMPM            ;ANY ERRORS ON SAVE-GET DEVICE?
459:         JRST CPOPJ1                     ;NO, GIVE OK RETURN
460: SGTERR: JSP TAC,PHOLD                   ;YES, PRINT MESS. AND STOP JOB
461:         ASCIZ \?
462: SAVE/GET IO ERROR\
463: 
464: NOROOM: PUSHJ PDP,SGREL                 ;RELEASE DEVICE, FIND TTY
465:         PUSHJ PDP,PRQM
466:         PUSHJ PDP,CRLF
467:         SKIPLE TAC,JOBCOR(JDAT)         ;GET MIN. HIGHEST REL.LOC. FOR JOB TO RUN
468:         JRST NOROM1                     ;USE IT IF SPECIFIED.
469:         HLRO TAC1,FILLEN(PROG)          ;-LENGTH OF FILE
470:         MOVNS TAC1                      ;+LENGTH
471:         HRRZ TAC,FILLEN(PROG)           ;FIRST LOC-1 DUMPED
472:         ADD TAC,TAC1                    ;LAST LOC DUMPED
473: NOROM1: LSH TAC,-12                     ;CONVERT TO NO. OF 1K BLOCKS-1
474:         ADDI TAC, 1
475:         PUSHJ PDP,RADX10
476:         JSP TAC,PHOLD                   ;GO START TTY, AND STOP JOB
477:         ASCIZ /K OF CORE NEEDED/
    COMCSS page# 0011 next  prev
479: ;ROUTINE TO RELEASE DEVICE AND FIND TTY
480: 
481: 
482: 
483: SGREL:  SKIPN USRJDA(PID)       ;HAS CHANNEL BEEN RELEASED ALREADY?
484:         JRST TTYFUW             ;YES. FIND TTY AND WAIT FOR OUTPUT TO FINSIH
485:         MOVE TAC,DEVMOD(DEVDAT)
486:         TLNE TAC,DVMTA          ;MAGTAPE?
487:         TLNN DEVDAT,INPB        ;YES. WAS AN INPUT DONE?
488:         JRST SGREL1             ;NO
489:         CLOSE 0,CLSOUT          ;YES. CLOSE INPUT.
490:         STATO 0,IOTEND          ;AT END OF TAPE?
491:         MTAPE 0,6               ;NO. SKIPTO EOF
492: SGREL1: RELEASE 0,              ;NO, RELEASE DEVICE
493:         JRST TTYFUW             ;FIND TTY AND WAIT FOR OUTPUT TO FINISH
    COMCSS page# 0012 next  prev
495: ;ROUTINE TO GET FILE FROM DEVICE
496: 
497: 
498: GETJB:  PUSHJ P,RESETSEG        ; FLUSH HIS UPPER SEGMENT IF ANY
499:         SETZM JOBINT(JDAT)      ; THIS WON'T GET CLEARED BY DMP FILE--RPH 1-6-74
500:         MOVE TAC,FILDAT(PROG)
501:         MOVEM TAC,JOBCRD(J)     ;COPY CREATION DATE FOR SEGMENT ACCESS
502:         MOVE TAC,DMPWRD(PROG)
503:         TLNE TAC1,DVDSK         ;DISK?
504:         HRRM TAC,FILLEN(PROG)   ;YES.
505:         HRRZ TAC,JOBCOR(PROG)   ;HIGHEST REL.LOC. REQUESTED
506:         MOVEM TAC,NEWCOR(PROG)  ;SAVE IT
507:         SETZM JOBCOR(PROG)      ;CLEAR JOBCOR SO NOROOM MESSAGE ALWAYS WORKS
508:         JUMPG TAC,GETJB1        ;WAS CORE SPECIFIED IN COMMAND STRING?
509:         TLNE TAC1,DVMTA         ;MAGTAPE?
510:         JRST GETJB3
511:         HLRO TAC1,FILLEN(PROG)  ;NO, USE AMOUNT SPECIFIED IN DIRECTORY
512:         JUMPGE TAC1,GETERR      ;DUMP FILE?
513:         HRRZ TAC,FILLEN(PROG)   ;FIRST LOC.-1
514:         SUB TAC,TAC1            ;TOTAL NO. OF WORDS NEEDED - 1=
515:                                 ;HIGHEST LOCATION DUMPED.
516:         IORI TAC,1777           ;HIGHEST LOC. IN 1K BLOCKS
517: GETJB1: MOVE ITEM,JOB(PID)      ;SETUP JOB NUMBER
518:         PUSHJ PDP,RUNCOR        ;TRY TO ASSIGN CORE
519:         JRST NOROOM             ;PRINT NO. OF BLOCKS NEEDED
520:         MOVE TAC1,DEVMOD(DEVDAT)
521:         TLNN TAC1,DVMTA         ;MAGTAPE?
522:         JRST GETJB2             ;YES
523: GETJB3: HLRZ TAC1,PROG          ;NO. SET FILLEN TO CURRENT CORE SIZE.
524:         SUBI TAC1,JOBSAV
525:         MOVNS TAC1
526:         HRLI TAC1,JOBSAV
527:         MOVSM TAC1,FILLEN(PROG)
528: GETJB2: PUSHJ PDP,SGDO          ;DO INPUT, RELEASE, FIND TTY
529:          INPUT 0,FILLEN         ;EXECUTED FROM SGDO
530:         MOVE TAC,JOBPPN(J)
531:         MOVEM TAC,FILLEN(PROG)  ;RESTORE PPN FOR PROG TO SEE
532:         HLRZ TAC,HILOC(JDAT)    ;SEGMENT PROTECTION SAVED HERE
533:                                 ;IF NO SEGMENT WAS SAVED, PROT WILL BE 0.
534:         ANDI TAC,377            ;FLUSH UNUSED BITS
535:         DPB TAC,[POINT 9,JOBCRD(J),8]
    COMCSS page# 0013 next  prev
537: ;HERE WE DISCOVER IF WE HAVE A HIGH SEGMENT TO SET-UP
538: ;FIRST TRY TO ATTACH TO THE SAVED NAME (IF ANY)
539: ;MAKE SURE IT IS WRITE PROTECTED, AND THAT IS WHAT WE WANT
540: ;IF ALL THIS FAILS, TRY A REMAP ON OUR SEGMENT.
541: 
542:         SKIPN TAC,HILOC(JDAT)   ; DOES THIS JOB HAVE A HIGH SEGMENT?
543:         JRST GETDN1             ; NO, FIX UP CORE SIZE AND LEAVE
544:         TLZ TAC,777777          ;ONLY INTERESTED IN RIGHT HALF
545:         IORI TAC,1777           ;WHERE IT WILL BE MOVED TO
546:         CAML TAC,USRREL(PID)    ;ADDRESS ABOVE TOP
547:         JRST GETERA             ;YES, EVIL EVIL(NOT A DUMP FILE)
548:         PUSH P,DDB              ;DDB CLOBBERED BY SEGMENT UUOS
549:         SKIPN TAC,HINAME(JDAT)  ;GET SAVED HIGH SEGMENT NAME!
550:         JRST GETJ5
551:         MOVEM TAC,FILLEN(PROG)
552:         ATTSEG FILLEN,          ;ATTACH TO IT?
553:         JRST GETJ5
554:         LDB TAC,PSEGN           ;GET ITS JOB NUMBER
555:         MOVE TAC,JBTSTS(TAC)
556:         SKIPL HILOC(JDAT)       ;DO WE WANT WRITE PROT?
557:         JRST GETJ7
558:         TLNE TAC,JWP            ;YES, IS HE WRITE PROTECTED
559:         JRST GETDON             ;PROT MATCHES
560:         JRST GETJ8
561: GETJ7:  TLNN TAC,JWP            ;IS HE UNPROTECTED?
562:         JRST GETDON             ;THAT'S IT!
563: GETJ8:  DETSEG                  ;DETACH THIS ONE
564: GETJ5:  HRRZ TAC,HILOC(JDAT)    ;CURRENT BOTTEM OF SEGMENT
565:         SUBI TAC,1
566:         PUSHJ P,BLTUP           ;MOVE UPPER TO NEXT 1K BOUNDARY
567:         MOVE TAC,HILOC(PROG)
568:         SUBI TAC,1
569:         IORI TAC,1777
570:         MOVEM TAC,FILLEN(PROG)
571:         REMAP FILLEN,           ; REMAP US
572:         CAIA
573:         JRST GETDN2
    COMCSS page# 0014 next  prev
575: ;END OF GET, REMAP ERROR, SETPR2 KLUDGE
576: 
577:         POP P,DDB               ;GET BACK TTY DDB
578:         MOVEI DAT,TTOBUF(DDB)   ;AND SET UP THIS GUY
579:         PUSHJ P,INLMES
580:         ASCIZ /
581: COULDN'T GET YOU A SEGMENT.  WILL TRY TO LET YOU WIN WITH SETPR2.
582: /
583:         HLRZ TAC,PROG
584:         MOVEM TAC,JOBCOR(PROG)  ;DON'T LET HIM CORE DOWN BELOW UPPER
585:         ADDI TAC,1
586:         MOVEM TAC,JOBFF(PROG)   ;AND TELL HIM NOT TO WRITE OVER IT
587:         HRLM TAC,JOBSA(PROG)    ;IN BOTH WAYS
588:         SUB TAC,FILLEN(PROG)    ;LENGTH OF UPPER+1
589:         MOVSI TAC,-2(TAC)
590:         SKIPL HILOC(PROG)
591:         TLZ TAC,1               ;SET UP W.P. BIT
592:         HRR TAC,FILLEN(PROG)
593:         ADDI TAC,1+3            ;REMOVE OFFSET AND SET "RELATIVE" & "PSEUDO-UPPER" BITS
594:         PUSHJ P,STPR2
595:         JRST GETDN1
596: 
597: GETERR: PUSHJ PDP,SGREL         ;RELEASE DEVICE AND FIND TTY
598: GETERA: JSP TAC,PHOLD
599:         ASCIZ /?
600: NOT A DUMP FILE/
601: 
602: GETDN2: SKIPN TAC,HINAME(JDAT)
603:         JRST GETDON
604:         LDB TAC1,PSEGN
605:         MOVE DDB,NJOBS(TAC1)
606: IFE FTSTAT,<CAIG DDB,1          ;MORE THAN ONE JOBS MEANS WE'RE NOT THE FIRST
607:         MOVEM TAC,JOBNAM(TAC1)
608: >;IFE FTSTAT
609: IFN FTSTAT,<
610:         CAILE DDB,1
611:         JRST GETDON
612:         MOVEM TAC,JOBNAM(TAC1)
613:         PUSH P,J
614:         MOVE J,TAC1
615:         PUSHJ P,NAMSTT
616:         POP P,J
617: >;FTSTAT
618: GETDON: POP P,DDB               ;GET BACK TTY DDB
619:         MOVEI DAT,TTOBUF(DDB)
620: GETDN1: SKIPE TAC,NEWCOR(PROG)  ;DID USER TYPE 3RD ARGUMENT?
621:         CAMG TAC,JOBCOR(JDAT)   ;YES, IS 3RD ARG GREATER THAN
622:                                 ;MIN SIZE SPECIFIED BY THIRD
623:                                 ;ARG TO SAVE (IF ANY)?
624:         MOVE TAC,JOBCOR(JDAT)   ;NO, ASSIGN NEW BIGGER AMOUNT OF CORE
625:         JUMPLE TAC,CPOPJ        ; IF 0 OR NEG, DOESN'T MAKE SENSE.
626:         IORI TAC,1777
627:         HLRZ TAC1,PROG          ; HOW MUCH DOES HE HAVE NOW
628:         CAMN TAC1,TAC           ; DIFFERENT?
629:         POPJ P,                 ;NO
630:         PUSHJ PDP,RUNCOR
631:         JFCL                    ;IGNORE IF CAN'T
632:         POPJ P,
    COMCSS page# 0015 next  prev
634: ; ROUTINE TO STUFF A FILE ON A DEVICE
635: 
636: SAVJB:  SETZM NEWCOR(PROG)      ;SIGNAL NO SAVE OF UPPER SEGMENT
637:         CAIA
638:                                 ; RESTORE PROJECT-PROGRAMMER NUMBER
639: SSAVJA: SETOM NEWCOR(PROG)      ;FLAG TO SAVE UPPER(IF ANY)
640:         MOVEM AC1,FILLEN(PROG)  ; TO THE LAST WORD OF THE LOOKUP BLOCK
641:                                 ; PLEASE NOTE THAT THIS MEANS THAT YOU CAN'T CLOBBER TAC OR AC1 BETWEEN CALLS ON SG1 AND SAVJB
642:         TLNN TAC1,DVDSK         ;DISK?
643:         MOVEM TAC,FILLEN(PROG)  ;NO. SET FILE LENGTH IN DIRECT. HEADER
644:         SETZM FILDAT(PROG)      ;MAKE SURE WE GET TODAY'S DATE
645:         TLNE TAC1,DVDSK         ;DISC?
646:         CLOSE 0,CLSOUT          ;YES, CLOSE INPUT
647:         ENTER 0,FILNAM          ;ENTER FILE NAME IN DIRECTORY
648:         JRST SAV4               ;DIRECTORY FULL
649:         MOVE TAC,DMPWRD(PROG)   ;RESTORE FILLEN AFTER DISC ENTER
650:         MOVEM TAC,FILLEN(PROG)
651:         MOVE TAC,JOB41(JDAT)    ;SAVE USER UUO HANDLING JSR
652:         MOVEM TAC,JOBS41(JDAT)  ;IN UPPER PART OF JOB DATA AREA
653:         SKIPN NEWCOR(PROG)      ;SHALL WE SAVE UPPER?
654:         JRST SAVJ1              ;NO
655:         LDB TAC,PSEGN
656:         JUMPE TAC,SAVJ1
657:         HLRZ TAC1,JBTADR(TAC)
658:         ADDI TAC1,1
659:         MOVNS TAC1
660:         MOVSS TAC1
661:         HRRI TAC1,377777
662:         MOVEM TAC1,NEWCOR(PROG)
663:         HLRO TAC1,FILLEN(PROG)
664:         SETCM TAC1,TAC1         ;COMPUTE +(LENGTH OF FIRST PART)-1
665:         IORI TAC1,177           ;MAKE IT A DISK BLOCK BOUNDARY-1
666:         ADDI TAC1,JOBSAV+1+1    ;ROUNDING UP AND MAKING INTO CORE LOC
667:         LDB TAC,PSEGN
668:         LDB TAC,[POINT 9,JOBCRD(TAC),8]
669:         HRL TAC1,TAC            ;SET SEGMENT PROT BITS IN LEFT HALF OF JOBRL2 TO GET SAVED
670:         LDB TAC,PSEGN           ;GET THIS BACK
671:         MOVE TAC,JBTSTS(TAC)
672:         TLNE TAC,JWP
673:         TLO TAC1,(1B0)
674:         MOVEM TAC1,JOBRL2(PROG) ;MAKE COMPATIBLE
675:         MOVEM TAC1,HILOC(PROG)
    COMCSS page# 0016 next  prev
677: ; SAVE ROUTINE
678: 
679:         LDB TAC,PSEGN           ;AND AGAIN
680:         MOVE TAC,JOBNAM(TAC)
681:         CAMN TAC,JOBNAM(J)      ;SAME NAMED UPPER AS LOWER
682:         SETZ TAC,               ;YES, FLAG AS SUCH
683:         MOVEM TAC,HINAME(JDAT)  ;SAVE IN THIS NEW PLACE!
684:         JRST SAVJ3
685: 
686: SAVJ1:  SETZM HILOC(JDAT)
687:         SETZM JOBRL2(PROG)
688:         SETZM HINAME(JDAT)
689:         SETZM NEWCOR(JDAT)      ;MAKE SURE NO SAVE HAPPENS!
690: SAVJ3:  SETZM DMPEND(PROG)
691:         HLRO TAC,FILLEN(PROG)
692:         SUBI TAC,JOBSAV
693:         ADD TAC,USRREL(PID)
694:         JUMPL TAC,NOROOM
695:         HLRO TAC,FILLEN(PROG)
696:         MOVNS TAC
697:         ADDI TAC,JOBSAV
698:         MOVEM TAC,JOBCOR(PROG)  ;MAKE SURE HE GETS TO BE RIGHT SIZE WHEN HE COMES BACK IN
699:         OUTPUT 0,FILLEN
700:         TRNE IOS,IOBKTL!IODERR!IODTER!IOIMPM
701:         JRST SGTERA
702:         SKIPN NEWCOR(PROG)
703:         JRST SGREL
704:         SETZM NEWCOR+1(PROG)
705:         OUTPUT 0,NEWCOR
706:         LDB TAC,PSEGN
707:         JUMPE TAC,SAVJ2
708:         HLRZ TAC1,JBTADR(TAC)
709:         TRO TAC1,400000
710:         MOVEM TAC1,HILOC(PROG)
711:         MOVEM TAC1,JOBRL2(PROG)
712: SAVJ2:  TRNN IOS,IOBKTL!IODERR!IODTER!IOIMPM
713:         JRST SGREL
714: SGTERA: PUSHJ P,SGREL
715:         JRST SGTERR
716: 
717: SAV4:   PUSHJ PDP,SGREL         ;RELEASE,DEVICE, FIND TTY
718:         JSP TAC,PHOLD           ;PRINT MESSAGE AND STOP JOB
719:         ASCIZ /?
720: ENTER FAILED!/
    COMCSS page# 0017 next  prev
722: BEGIN SEGCSSSUBTTL   SEGCSS  8 SEPT 69       JAM
723: ; SEGMENT ACCESS CONTROL
724: ; PUT JOB NUMBER OF MASTER ON STACK AND NUMBER OF SEGMENT IN J
725: ; CALLING . . .
726: ;       PUSH PDP,ITEM
727: ;       MOVE ITEM,<SEGMENT NUMBER>
728: ;       PUSHJ PDP,ACCESS
729: ;       <NO ACCESS POSSIBLE>
730: ;       <READ ACCESS ONLY>
731: ;       <ALL ACCESS LEGAL>
732: 
733: ACCESS:MOVE TAC,-1(P)          ; PICK UP MASTER JOB NUMBER
734:         MOVE TAC1,JBTPRV(TAC)   ; GET PRIV BITS OF MASTER
735:         TLNE TAC1,SEGPRV        ; DO WE HAVE THE PRIVILEGE?
736:         JRST CPOPJ2             ; YES, AUTOMATIC SUCCESS
737:         MOVE TAC1,PRJPRG(TAC)
738:         LDB TAC,[POINT =9,JOBCRD(J),8]
739:         TRZE TAC,400            ;UNPURIFIED?
740:         JRST ACCES2             ;YES - DIFFERENT TEST (TAC IS NOW JOB # OF DEFILER)
741:         CAMN TAC1,JOBPPN(J)     ; IS THIS THE SAME JOB?
742:         JRST ACCES1             ; YES, USE OWNER'S PROTECTION
743:         XOR TAC1,JOBPPN(J)
744:         TRNE TAC1,-1            ;SAME PROGRAMMER?
745:         LSH TAC,3               ; NO, MOVE OVER TO GENERAL PROTECTION
746:         LSH TAC,3               ; MOVE OVER TO PROGRAMMER PROTECTION
747: ACCES1: TRNN TAC,300            ; NOW, IS THERE ANY PROTECTION?
748:         JRST CPOPJ2             ; NO, EVERYTHING GOES
749:         TRNN TAC,200            ; IS IT READ PROTECTED?
750:         AOS (P)                 ; NO, IT CAN BE READ
751:         POPJ P,                 ; OTHERWISE INACCESSABLE
752: 
753: ACCES2: CAMN TAC,-1(P)          ;ONLY ORIGINAL OWNER WINS HERE
754:         JRST CPOPJ2
755:         POPJ P,
    COMCSS page# 0018 next  prev
757: ; ROUTINE TO INVENT AN UPPER SEGMENT
758: ; SKIP RETURNS WITH JOB NUMBER OF SEGMENT IN J; NON SKIP IF JOB CAPACITY EXCEEDED
759: ; SETS CORE SIZE TO ZERO, SETS PPN TO *SEG*, SETS AS DETATCHED
760: 
761: ESTSEG:
762:         MOVEI   J,1
763:         MOVSI   TAC,JNA!JLOG!JACCT!CMWB         ;JNA IS PROBABLY ENOUGH
764: ESTSE1: TDNN    TAC,JBTSTS(J)                   ;SKIP IF JOB SLOT IN USE.
765:         JRST    ESTSE2                          ;WE HAVE A SLOT TO USE.
766:         CAMGE   J,JOBNM1                        ;HAVE WE SEEN ALL SLOTS?
767:         AOJA    J,ESTSE1                        ;NOT YET.
768:         MOVEI   J,0                             ;RETURN A ZERO
769:         POPJ    P,                              ;FAILURE.
770: 
771: ESTSE2:
772:                 SKIPE   JBTADR(J)       ;BUG TRAP
773:                 PUSHJ   P,INIJXX        ;MAKE LOSE MESSAGE
774:         SETZM   JBTADR(J)                       ;NO CORE ANYWHERE.
775:         MOVSI   TAC,JSEG!JNA!JLOG               ;SET SEGMENT, SLOT USED, LOGGED IN
776:         IORM    TAC,JBTSTS(J)                   ;IN JOB STATUS FOR SEGMENT
777:         SETZM   NJOBS(J)                        ;NO ONE USING THIS UPPER YET
778:         SETOM   JBTLIN(J)                       ;DETACHED
779:         SETZM   TTIME(J)                        ;NO RUN TIME FOR THIS UPPER
780:         SETZM   XTIME(J)                        ;NO XTIME
781:         SETZM   DSKOPS(J)                       ;NO DISK OPS
782:         MOVE    TAC,TIMDAT
783:         MOVEM   TAC,FTIME(J)                    ;SET UP JOB LAST RUN TIME.
784:         MOVE    TAC,[SIXBIT /*SEG*/]            ;PPN = *SEG*
785:         MOVEM   TAC,PRJPRG(J)
786:         MOVEI   TAC,STOPQ                       ;QUEUE US INTO THE STOPQ
787:         MOVNM   TAC,JOBQUE(J)
788:         AOS     (P)                             ;SETUP SKIP RETURN
789:         JRST    REQUE
    COMCSS page# 0019 next  prev
791: ; THIS ROUTINE DEFINES A SEGMENT. IT SEARCHES FOR AN EXISTING
792: ; SEGMENT FIRST WITH THE PROPER CREDENTIALS AND GIVES YOU ITS NUMBER FIRST.
793: ; OTHERWISE, IT MAKES ONE UP AND PUTS YOUR ID IN ITS CREDENTIALS. RETURNS
794: ; THE NUMBER OF THE SEGMENT IN JBTSTS, 0 FOR FAILURE.
795: 
796: LINKSEG:
797:         PUSHJ   P,KILSEG        ;GET RID OF EXISTING UPPER.
798:         PUSH    P,J
799:         MOVE    AC1,J           ; SAVE NUMBER OF MASTER JOB
800:         MOVE    J,JOBNM1
801: DEFSE1: MOVE    TAC,JBTSTS(J)   ;LOOK FOR AN UPPER.
802:         TLNN    TAC,JSEG
803:         JRST    DEFSE2          ;NOT AN UPPER. SKIP IT.
804:         MOVE    TAC,JOBNAM(J)
805:         MOVE    TAC1,JOBPPN(J)
806:         CAMN    TAC,JOBNAM(AC1) ;DOES THE JOB NAME MATCH?
807:         CAME    TAC1,JOBPPN(AC1);AND DOES THE PROJ-PROG NAME MATCH?
808:         JRST    DEFSE2          ; NO
809:         MOVE    TAC,JOBCRD(J)
810:         MOVE    TAC1,JOBDEV(J)
811:         CAMN    TAC,JOBCRD(AC1) ;DOES THE CREATION DATE AND PROTECTION MATCH?
812:         CAME    TAC1,JOBDEV(AC1);AND DOES THE DEVICE MATCH?
813:         JRST    DEFSE2          ;NO
814:         MOVE    TAC,JOBLOG(J)   ;CHECK LOGICAL NAME TOO
815:         CAMN    TAC,JOBLOG(AC1)
816:         PUSHJ   P,ACCESS        ;NOW, CAN WE LEGALLY ACCESS THIS SEGMENT?
817:         JRST    DEFSE2          ;NO
818:         JFCL
819: DEFSE3: MOVE    TAC,J
820:         POP     P,J
821:         DPB     TAC,PSEGN
822: IFN FTSTAT, <PUSHJ P,SEGSTT
823:         LDB TAC,PSEGN
824: >
825:         AOS     NJOBS(TAC)      ;BUMP COUNT OF NUMBER OF PEOPLE POINTING TO HIM
826:         SKIPE   TAC
827:         AOS     (P)
828: SEGXIT: CAME J,JOB(PID)
829:         JRST SEGXT1
830:         PUSHJ P,GETPR
831:         DATAO APR,TAC
832: SEGXT1: POPJ P,
833: 
834: DEFSE2: SOJG J,DEFSE1
835:         POP P,J
836:         POPJ P,
837: 
838: MAKESEG:
839:         PUSHJ   P,KILSEG
840:         PUSH    P,J
841:         PUSHJ   P,ESTSEG        ; IF NO EXISTING ONE, MAKE ONE UP
842:         JRST    DEFSE3          ; IF NOT AVAILABLE, JUST LEAVE
843:         MOVE    TAC,J           ;SAVE SEGMENT NUMBER
844:         POP     P,J
845:         DPB TAC,PSEGN
846: IFN FTSTAT,<
847:         PUSHJ P,SEGSTT
848:         LDB TAC,PSEGN
849: >;FTSTAT
850: MAKSE2:AOS NJOBS(TAC)          ; BUMP COUNT OF PEOPLE POINTING TO HIM
851:         MOVE TAC1,JOBNAM(J)     ; NOW ESTABLISH ITS CREDENTIALS
852:         MOVEM TAC1,JOBNAM(TAC)
853: IFN FTSTAT,<
854:         PUSH P,J
855:         MOVE J,TAC
856:         PUSHJ P,NAMSTT
857:         POP P,J
858: >;FTSTAT
859:         MOVE TAC1,JOBPPN(J)
860:         MOVEM TAC1,JOBPPN(TAC)
861:         MOVE TAC1,JOBCRD(J)
862:         MOVEM TAC1,JOBCRD(TAC)
863:         MOVE TAC1,JOBDEV(J)
864:         MOVEM TAC1,JOBDEV(TAC)
865:         MOVE TAC1,JOBLOG(J)
866:         MOVEM TAC1,JOBLOG(TAC)
867:         POPJ P,
    COMCSS page# 0020 next  prev
869: ; ROUTINE TO KILL A HIGH SEGMENT
870: ; ENTER WITH JOB NUMBER OF OWNER IN J
871: ; IF OTHER PEOPLE POINT TO IT, IT WILL REMAIN
872: ; IF NO-ONE ELSE POINTS TO IT, IT WILL GO AWAY
873: 
874: ↑↑KILSEG:
875:         SKIPE   JBTPR2(J)               ;IS HE DOING PEEK-POKE?
876:         JRST    [SETZM  JBTPR2(J)       ;YES, MUST KILL IT HERE
877:                 JRST    SEGXIT]
878:         PUSH    P,J                     ;SAVE JOB NUMBER.
879:         LDB     J,PSEGN                 ;GET OUR SEGMENT NUMBER
880:         JUMPN   J,KILSE6                ;JUMP IF THERE IS A SEGMENT
881:         POP     P,J                     ;THERE'S NO SEGMENT. FORGET IT
882:         POPJ    P,
883: 
884: KILSE6: PUSH    P,J                     ;SAVE SEGMENT NUMBER.
885:         SKIPA   J,JOBNM1                ;SEARCH FOR ANY OTHERS POINTING HERE
886: KILSE3: SOJLE   J,KILSE1                ;DECREMENT J. JUMP IF JOB LIST EXHAUSTED
887:         CAMN    J,-1(P)                 ;IS THIS THE CURRENT JOB?
888:         JRST    KILSE3                  ;YES. WE KNOW ABOUT HIM, SO SKIP IT.
889:         LDB     TAC,PSEGN
890:         CAMN    TAC,(P)                 ;DOES HE POINT TO OUR SEGMENT?
891:         JRST    KILSE4                  ;YES. - DON'T KILL SEGMENT.
892: KILSE7: SKIPN   AC1,JBTDTS(J)           ;DOES THIS GUY HAVE A DETACHED SEGMENT LIST?
893:         JRST    KILSE3                  ;NO.
894: KILSE5: LDB     TAC,PDSEGN              ;LOOK THRU DET SEG LIST
895:         JUMPE   TAC,KILSE3              ;JUMP WHEN DET SEG LIST IS EMPTY
896:         CAME    TAC,(P)                 ;SAME AS THIS SEGMENT?
897:         AOJA    AC1,KILSE5              ;NO. KEEP LOOKING.
898: KILSE4: POP     P,J                     ;SOMEONE ELSE POINTS TO THIS SEGMENT
899: KILSE2: SOSGE   NJOBS(J)
900:         PUSHJ   P,[
901:                 PUSHACS
902:                 PUSHJ   P,DISMES
903:                 ASCIZ   /NJOBS WENT NEGATIVE AT KILSE2
904: /
905:                 POPACS
906:                 SETZM   NJOBS(J)
907:                 POPJ    P,]
908:         POP     P,J                     ;POP CURRENT JOB NUMBER
909:         MOVEI   TAC,0
910:         DPB     TAC,PSEGN               ;ZERO SEGMENT FIELD
911: IFN FTSTAT,<
912:         PUSHJ P,SEGSTT
913:         LDB TAC,PSEGN
914: >;FTSTAT
915:         JRST    SEGXIT
916: 
917: ;HERE  IF THERE ARE NO FURTHER REFERENCES TO THIS SEGMENT.
918: KILSE1: POP     P,J                     ;GET THE SEGMENT NUMBER
919:         PUSHJ   P,ZEROSEG               ;EXPUNGE SEGMENT
920:         MOVE    TAC,NJOBS(J)
921:         CAIE    TAC,1                   ;THERE SHOULD BE ONLY 1 POINTER TO THIS
922:         PUSHJ   P,NZERR
923:         JRST    KILSE2
924: 
925: NZERR:  PUSHACS
926:         PUSHJ   P,DISMES
927:         ASCIZ   /NJOBS NOT ZERO AT KILSEG
928: /
929:         POPACS
930:         POPJ    P,
    COMCSS page# 0021 next  prev
932: ; ROUTINE TO ERASE A SEGMENT ENTIRELY
933: 
934: ZEROSEG:PUSH    P,JDAT
935: ZERO1:  MOVE    JDAT,JBTADR(J)
936:         SETZM   TAC
937:         PUSHJ   P,CORE0                 ;GIVE BACK THIS SEGMENT'S CORE
938:         JRST    ZERO5
939:         MOVE    TAC,JOBNM1              ;LOOK FOR FATHER JOB.
940: ZERO3:  LDB     TAC1,[POINT 6,JBTSTS(TAC),35]
941:         CAME    TAC1,J
942: ZERO4:  SOJG    TAC,ZERO3
943:         JUMPE   TAC,ZERO2
944:         SKIPN   JBTST2(TAC)             ; WAS THERE A SPW MODULE HERE
945:         JRST    ZERO4                   ; NO.
946:         MOVSI   TAC1,SPWST1!SPWST2      ; YES, CLEAR THE SPACEWAR STOPPED BITS
947:         PSYNC   SPWCSC
948:         ANDCAM  TAC1,JBTST2(TAC)
949:         XSYNC   SPWCSC
950:         JRST    ZERO4                   ;THERE AREN'T SUPPOSED TO BE ANY MORE ...
951: 
952: ZERO2:  MOVSI   TAC,JSEG!JWP!JNA!JLOG!JACCT!RUN
953:         ANDCAM  TAC,JBTSTS(J)
954:         SETZM   JOBNAM(J)
955:         SETZM   PRJPRG(J)
956:         MOVEI   TAC,NULQ
957:         MOVNM   TAC,JOBQUE(J)
958:         PUSHJ   P,REQUE
959:         PUSHJ   P,FBFLUSH
960:         POP     P,JDAT
961:         POPJ    P,
962: 
963: ZERO5:  PUSHJ   P,WSCHED                ; WAIT FOR SPW TO STOP.
964:         JRST    ZERO1
    COMCSS page# 0022 next  prev
966: ; ROUTINE TO FLUSH A JOB'S HIGH SEGMENT AND ALL THE SEGMENTS HE MAY HAVE
967: ; PREVIOUSLY DETACHED, IF AND ONLY IF NO ONE ELSE IS POINTING AT THEM.
968: ; CALL FROM UUO OR CLOCK LEVEL ONLY!!!!!!
969: 
970: ↑↑FLUSHSEG:
971:         PUSHJ   P,KILSEG                ;KILL HIS IMMEDIATE UPPER
972:         SKIPN   AC1,JBTDTS(J)           ;IS THERE A DET SEG LIST?
973:         POPJ    P,                      ;NO. THIS IS EASY.
974:         PUSH    P,J                     ;SAVE CALLING JOB'S NUMBER
975: FLUSH1: MOVE    J,(AC1)                 ;GET THE NUMBER OF THE DETACHED SEGMENT
976:         JUMPE   J,FLUSH2                ;JUMP IF THERE ARE NO MORE.
977:         JUMPL   J,FLUSH6                ;JUMP IF THIS IS SPECIAL DETACHED.
978:         MOVE    TAC1,JOBNM1
979:         ANDI    J,77                    ;SEGMENT NUMBER ONLY.
980: FLUSH3: LDB     TEM,[POINT 6,JBTSTS(TAC1),35]           ;DO OTHERS POINT HERE?
981:         CAMN    TEM,J                   ;DIRECT MATCH?
982: FLUSH6: AOJA    AC1,FLUSH1              ;YES. CAN'T BE FLUSHED.
983:         CAME    TAC1,(P)                ;DON'T MATCH AGAINST OUR OWN JOB
984:         SKIPN   DAT,JBTDTS(TAC1)        ;DOES THIS JOB HAVE A DETACH LIST?
985:         JRST    FLUSH5                  ;NO, GO TO NEXT JOB
986: FLUSH4: LDB     TEM,[POINT 6,(DAT),35]  ;YES, PICK UP ITS SEGMENT NUMBER
987:         JUMPE   TEM,FLUSH5              ;JUMP IF END OF LIST
988:         CAMN    TEM,J                   ;DOES HE POINT TO US?
989:         AOJA    AC1,FLUSH1              ;YES, CAN'T ZERO THIS SEGMENT
990:         AOJA    DAT,FLUSH4              ;NO, TRY NEXT DETACHED SEGMENT
991: 
992: FLUSH5: SOJG    TAC1,FLUSH3             ;LOOP AROUND FOR NEXT JOB
993:         MOVE    TAC,JBTSTS(J)           ;NOW, DOES THIS SEGMENT STILL EXIST?
994:         TLNN    TAC,JNA
995:         AOJA    AC1,FLUSH1              ;NO, DON'T BOTHER
996:         PUSH    P,AC1
997:         PUSHJ   P,ZEROSEG               ;WIPE OUT THAT SEGMENT, NO OTHER REFERENCES TO IT
998:         SKIPE   NJOBS(J)
999:         PUSHJ   P,NZERR
1000:         POP     P,AC1
1001:         AOJA    AC1,FLUSH1
1002: 
1003: FLUSH2: POP     P,J
1004:         MOVE    AC1,JBTDTS(J)           ;SEARCH FOR SPECIAL DET SEG.
1005:         MOVEI   AC2,(AC1)               ;AC1 POINTS AT HOLE. AC2 POINTS AT DATUM
1006: FLUSH7: SKIPLE  TAC,(AC2)               ;SKIP IF SPECIAL OR EMPTY
1007: FLUSH8: AOJA    AC2,FLUSH7              ;NORMAL DET SEG. GET NEW DATUM
1008:         MOVEM   TAC,(AC1)               ;DATUM IS BUBBLED DOWN.
1009:         JUMPE   TAC,FLUSH9              ;JUMP IF DONE.
1010:         AOJA    AC1,FLUSH8              ;ADVANCE HOLE, ADVANCE DATUM.
1011: 
1012: FLUSH9: CAME    AC1,JBTDTS(J)           ;IS HOLE IS STILL IN THE SAME PLACE?
1013:         POPJ    P,                      ;NO. WE STILL HAVE A DET SEG LIST.
1014:         PUSHJ   P,FSGIVE
1015:         SETZM   JBTDTS(J)
1016:         POPJ    P,
1017: 
1018: ↑↑DSFLUSH:                              ;MAKE SPECIAL DET SEG INTO ORDINARY.
1019:         SKIPN   AC1,JBTDTS(J)
1020:         POPJ    P,
1021: DSFL1:  MOVSI   TAC,400000
1022:         ANDCAB  TAC,(AC1)
1023:         JUMPE   TAC,CPOPJ
1024:         AOJA    AC1,DSFL1
1025: 
1026: 
    COMCSS page# 0023 next  prev
1028: ; UAPPLY - APPLY A ROUTINE TO ALL LOWERS OF AN UPPER.
1029: ;CALL:
1030: ;       MOVE    J,<UPPER'S NUMBER>
1031: ;       PUSHJ   P,UAPPLY
1032: ;       <INSTRUCTION TO XCT>    ;J HAS LOWER'S NUMBER, DDB HAS UPPER'S NUMBER
1033: ;       RETURN HERE
1034: ;THE SUBJECT INSTRUCTION SHOULD NOT SKIP.  NO AC'S ARE CLOBBERED EXCEPT BY
1035: ;THE XCT'ED INSTRUCTION.  DDB AND J SHOULD NOT BE USED TO RETURN ARGUMENTS, ETC.
1036: 
1037: ↑↑UAPPLY:       
1038:         PUSH    P,DDB
1039:         PUSH    P,J
1040:         MOVEI   J,JOBN-1
1041: UAPP1:  LDB     DDB,PJOBN       ;GET NUMBER OF THIS LOWER'S UPPER
1042:         CAMN    DDB,(P)
1043:         JRST    UAPP3           ;MATCHES.
1044: UAPP2:  SOJG    J,UAPP1
1045:         POP     P,J
1046:         POP     P,DDB
1047:         JRST    CPOPJ1
1048: 
1049: UAPP3:  PUSH    P,J
1050:         XCT     @-3(P)          ;J = JOB NUMBER OF LOWER, DDB = JOB NUMBER OF UPPER.
1051:         POP     P,J
1052:         JRST    UAPP2
1053: 
1054: BEND SEGCSS
    COMCSS page# 0024 next  prev
1056: SUBTTL  COMCSS  4 AUG 67
1057: 
1058: ;ROUTINE TO RETURN NEXT ALPHANUMERIC STRING
1059: ; IN COMMAND LINE (SIXBIT)
1060: ;CALL:  MOVE TAC,BYTE POINTER TO PREVIOUS CHAR.
1061: ;       PUSHJ PDP, CTEXT
1062: ; SIXBIT STRING RETURN LEFT JUSTIFIED IN AC TAC1
1063: 
1064: 
1065: CTEXT: PUSHJ PDP,SKIPS         ; SKIP LEADING SPACES, TABS, NULLS, AND CLEAR TAC1
1066:         CAIA
1067: CTEXT1:
1068:         PUSHJ PDP,SKIPS1
1069:                                 ;DO NOT RETURN IF CR WAS PREVIOUS BREAK
1070:         MOVE UCHN,[POINT 6,TAC1]
1071:         LDB TEM,TAKR(DAT)
1072:         ANDI TEM,177
1073:         CAIG TEM,"Z"+40
1074:         CAIGE TEM,"A"+40
1075:         JRST CTEX1
1076:         SUBI TEM,40
1077:         JRST CTEX1
    COMCSS page# 0025 next  prev
1079: CTEX0:  PUSHJ PDP,GETLCCHR
1080: CTEX1:  PUSHJ PDP, CTEX         ;IS IT ALPHANUMERIC
1081:         TRC TEM,40              ;CONVERT TO SIXBIT
1082:         TLNE UCHN,770000                ; HAVE WE ACCUMULATED 6 CHARS?
1083:         IDPB TEM,UCHN           ;NO, STORE AWAY
1084:         JRST CTEX0              ; YES
1085: 
1086: ;SCAN FOR ALPHANUMERIC CHAR IN TEM
1087: CTEX:   CAIL TEM, "0"
1088:         CAILE TEM, "Z"          ;LETTERS ARE LARGER THAN NOS.
1089:         JRST CTEXA              ;NEITHER
1090:         CAILE TEM, "9"
1091:         CAIL TEM, "A"
1092:         POPJ PDP,               ;LETTER OR NUMBER RETURN
1093: CTEXA:
1094:         CAIN TEM,":"            ; DEVICE NAME?
1095:         PUSHJ PDP,GETLCCHR      ; YES, SKIP COLON
1096:         CAIE TEM,0              ; ↑C?
1097:         JRST TPOPJ              ; NO, RETURN UP ONE LEVEL
1098: CTXCNC: MOVSI TAC1,'HAL'        ; CUE UP A PHONY 'HALT'
1099:         MOVEI TEM,12            ; TERMINATE WITH LINE FEED
1100:         DPB TEM,TAKR(DAT)       ; STORE IN INPUT BUFFER DO ↑C NOT SEEN
1101:         JRST TPOPJ              ; AND RETURN UP A LEVEL
1102: 
1103: 
1104: GETLCCHR:
1105:         PUSHJ P,GETCHR
1106:         CAIG TEM,"Z"+40
1107:         CAIGE TEM,"A"+40
1108:         POPJ P,
1109:         SUBI TEM,40
1110:         POPJ P,
    COMCSS page# 0026 next  prev
1112: ;ROUTINE TO IGNORE LEADING SPACES, TABS, AND NULLS
1113: ;ALSO CLEARS TAC1
1114: ;DOES NOT RETURN IF PREVIOUS CHAR. OR NEXT NON-SPACING
1115: ;CHAR. IS CR(IE POPS SUBROUTINE LEVEL UP 1 ON RETURN)
1116: ;CALL:  MOVE TAC,BYTE POINTER TO PREVIOUS BREAK CHAR.
1117: ;       PUSHJ PDP, SKIPS1
1118: 
1119: 
1120: SKIPSJ: PUSHJ P,SKIPS1
1121:         POPJ P,
1122: 
1123: SKIPS:  PUSHJ PDP,GETLCCHR      ; GET FIRST CHAR ON LINE
1124: SKIPS1: MOVEI TAC1,0            ; FOR CTEXT AND DECIN
1125:         LDB TEM,TAKR(DAT)       ; IN CASE TEM IS CLOBBERED
1126:         ANDI TEM,177
1127:         CAIE TEM,"."            ; IF A PERIOD, GET NEXT CHARACTER
1128:         CAIN TEM,15             ; SKIP TO L.F. IF C.R.
1129: SKIPSA: PUSHJ PDP,GETLCCHR      ; GET NEXT CHARACTER
1130: SKIPSB: JUMPE TEM,SKIPS3        ; LEAVE IF NO MORE CHARS
1131:         CAIN TEM,";"            ; STOP HIM AT SEMI-COLON
1132:         JRST SKIPS3             ; MAKE IT LOOK LIKE END OF LINE
1133:         PUSHJ PDP,SPCHEK        ; IS THIS A SPECIAL CHAR?
1134:         JRST SKIPS2             ; NO
1135:         TLNE TAC,BREAKB         ; BREAK? END OF LINE?
1136:         JRST SKIPS3             ; YES, LEAVE
1137: SKIPS2: CAIG TEM,40             ; SPACE OR CONTROL CHAR?
1138:         JRST SKIPSA             ; YES
1139:         POPJ PDP,               ; NO, RETURN
1140: 
1141: SKIPS3: JUMPE TEM,CTXCNC        ; ↑C?
1142:         MOVEI TEM,12            ; WE USE LINE FEEDS FOR BREAK CHARS
1143:         JRST TPOPJ              ; RETURN UP ONE LEVEL
    COMCSS page# 0027 next  prev
1145: ;ROUTINE TO APPEND A "?" TO INPUT STRING AND SET AS OUTPUT
1146: ;CALLED FROM OCTIN, RETURNS TO SECOND LEVEL ON PDL
1147: ;CALL:  MOVE TAC, BYTE POINTER TO LAST CHAR. IN INPUT STRING
1148: ;       PUSHJ PDP, COMERA
1149: 
1150: 
1151: COMEND:
1152:         PUSHJ P,SKIPS1          ; IF ANYTHING LEFT IN INPUT LINE, FALL INTO COMERA
1153: COMERP:
1154:         POP PDP,UCHN            ; REMOVE SUBROUTINE RETURN BEFORE CALLING COMERA
1155: COMERA:
1156:         PUSHJ PDP,GETCHR
1157: 
1158: 
1159: ;ROUTINE TO REPLACE LAST CHARACTER IN INPUT STRING BY "?"
1160: ;AND SET AS OUTPUT
1161: ;CALL:  MOVE TAC, BYTE POINTER TO LAST CHAR. IN INPUT STRING
1162: ;       PUSHJ PDP, COMERR
1163: 
1164: 
1165: 
1166: COMERR:
1167:         MOVE UCHN,TITCTR(DEVDAT)        ; SAVE POSITION IN SCAN
1168:         PUSHJ PDP,TRESCN        ; BACK UP TO START OF COMMAND
1169: COMERL: PUSHJ PDP,GETCHR        ; GET A CHARACTER FROM COMMAND LINE
1170:         JUMPE TEM,COMER1        ;QUIT ON NULL HERE!
1171:         CAMN UCHN,TITCTR(DEVDAT)        ; HAVE WE PASSED A BAD CHAR YET?
1172:         JRST COMER1             ; YES
1173:         PUSHJ PDP,OUTCHS        ; NO, TYPE CHARACTER
1174:         JRST COMERL             ; AND LOOP FOR ANOTHER
1175: 
1176: COMER1: PUSHJ PDP,SETBFI        ; CLEAR ANY MORE TYPE IN
1177:         MOVEI TEM,"?"           ; APPEND ? TO ERRONEOUS WORD
1178:         PUSHJ PDP,OUTCHS        ; AND PRINT IT
1179:         MOVSI J,NOJOBN!NOINCK   ;NOW WE PAINSTAKINGLY FAKE OUT COMRET
1180:         IORM J,-1(P)            ;*** IF YOU CALL COMERR FROM ANYPLACE THAT
1181:         MOVSI J,NOPER!NOCRLF    ;*** DOESN'T HAVE COMRET NEXT ON THE PDL
1182:         ANDCAM J,-1(P)          ;*** BOY ARE YOU IN BAD TROUBLE!
1183:         TDZA ITEM,ITEM          ; CLEAR JOB NUMBER AND SKIP INTO CRLF ROUTINE
    COMCSS page# 0028 next  prev
1185: ;ROUTINE TO PRINT A COMMAND ERROR MESSAGE
1186: ;SAME CALL AS CONMES
1187: 
1188: 
1189:                                 ;COMERR SKIPS THIS ROUT.(SEE ABOVE)
1190: ERRMES:
1191:         TDZA ITEM,ITEM          ; CLEAR JOB NUMBER TO INDICATE ERROR
1192:                                 ;SKIP INTO CONMES ROUTINE
1193: 
1194: ;ROUTINE TO PRINT CARRIAGE RETURN-LINE-FEED
1195: ;CALL:  MOVE DAT,BYTE POINTER TO OUTPUT
1196: ;       PUSHJ PDP,CRLF
1197: 
1198: 
1199:                                 ;COMERR SKIPS TO HERE(SEE ABOVE)
1200: CRLF:  MOVEI TAC,[BYTE (7) 15,12,0]
1201: 
1202: ;ROUTINE TO MOVE ASCII CHAR. STRING TO CONSOLE OUTPUT BUFFER
1203: ; CALL: MOVE DAT, BYTE POINTER TO LAST OUTPUT CHARACTER
1204: ;       MOVEI TAC,  ADDRESS OF ASCII MESSAGE
1205: ;       PUSHJ PDP, CONMES
1206: ; STRING TERMINATED BY NULL
1207: ; CONMES DOES NOT START TTY
1208: 
1209:                                 ;ERRMES SKIPS TO HERE
1210: CONMES:
1211:         HRLI TAC,440700         ; FORM ASCIZ BYTE POINTER
1212:         PUSH PDP,TAC            ;SAVE BYTE POINTER
1213: CON0:   ILDB TEM,(PDP)          ;GET NEXT CHAR.
1214:         JUMPE TEM,TPOPJ         ;IS IT NULL?(IF YES, DO POP P,TAC, POPJ)
1215: TYO:
1216: CONTYO:
1217:         PUSHJ PDP,OUTCHS
1218:         JRST CON0               ;KEEP GOING
    COMCSS page# 0029 next  prev
1220: ;ROUTINE TO PRINT INLINE ASCIZ MESSAGE - INLMES, PRCRCC, PRCNCC
1221: ;CALL:  PUSHJ PDP,INLMES
1222: ;       ASCIZ /THE MESSAGE/
1223: ;RETURN TO NEXT LOC AFTER MESSAGE
1224: 
1225: 
1226: INLMES:
1227:         POP PDP,TAC             ; SETUP PRINT ADRESS FOR CONMES
1228:         PUSHJ PDP,CONMES
1229:         JRST 1(TAC)             ;RETURN TO NEXT LOC AFTER MESSAGE
1230: 
1231: ;ROUTINE TO APPEND ? TO ERROR MESSAGE
1232: ;CALL   PUSHJ PDP,PRQM
1233: ;       RETURN
1234: 
1235: 
1236: PRQM:  MOVEI   TEM,"?"
1237:         XCT     TYO
1238:         POPJ    P,
1239: 
1240: PRSPC:  MOVEI TAC,[ASCIZ /    /]        ;DEC 3.16
1241:         JRST CONMES                     ;DEC 3.16
1242: 
1243: ;ROUTINE TO PRINT "TOO FEW ARGUMENTS"
1244: ;CALL:  MOVE DAT,BYTE POINTER
1245: ;       PUSHJ PDP,NOTENF
1246: 
1247: 
1248: NOTENF:
1249:         JSP TAC,ERRMES
1250: 
1251: ASCIZ /TOO FEW ARGUMENTS
1252: /
1253: 
1254: ;ROUTINE TO PRINT A PERIOD
1255: ;CALL:  PUSHJ PDP,PRPER
1256: 
1257: 
1258: PRCRCC:PUSHJ P,CRLF
1259: PRCNTC:PUSHJ P,INLMES
1260:         ASCIZ /↑C
1261: /
1262: PRPER: MOVEI   TEM,"."
1263:         JRST    OUTCHS
1264: 
    COMCSS page# 0030 next  prev
1266: ;ROUTINE TO DEASSIGN A DEVICE
1267: ;CALL:  MOVE DEVDAT, DEVICE DATA BLOCK
1268: ;       MOVE ITEM, JOB NUMBER
1269: ;       PUSHJ PDP, DEASG
1270: ;       ERROR NOT PREVIOUSLY ASSIGNED
1271: ;       OK RETURN WITH DEVICE DEASSIGNED
1272: 
1273: 
1274: 
1275: DEASG: LDB UCHN, PJOBN         ;WAS DEVICE ASSIGNED TO THIS JOB?
1276:         CAME UCHN, ITEM
1277:         POPJ PDP,               ;NO, RETURN
1278:         PUSH PDP,ITEM           ;SAVE JOB NUMBER
1279:         MOVSI UCHN,DVDIRIN              ;CLEAR DIRECTORY IN CORE BIT
1280:         ANDCAM UCHN,DEVMOD(DEVDAT)
1281:         SETZM DEVLOG(DEVDAT)    ;CLEAR LOGICAL NAME
1282:         MOVEI TAC1,ASSCON       ;IS DEVICE ASSIGNED BY CONSOLE?
1283:         TDNE TAC1,DEVMOD(DEVDAT)
1284:         AOS -1(PDP)             ;YES, DO OK RETURN
1285:         PUSHJ PDP,RELEA6        ;CLEAR JOB NO. IN DDB IF DDB NOT NEEDED
1286:         POP PDP,ITEM            ;BY THIS JOB ANY MORE
1287:         POPJ PDP,
1288: 
1289: ;ROUTINE TO DEASSIGN ALL DEVICES EXCEPT LOGICAL TTY
1290: ;CALL:  MOVE ITEM, JOB NUMBER
1291: ;       MOVE DEVDAT,ADR. OF DEVICE NOT TO BE DEASSIGNED
1292: ;       PUSHJ PDP, DEASTY
1293: 
1294: 
1295: 
1296: 
1297: DEASTY:
1298:         HRRZS DDB               ; CLEAN OUT THE LH SHIT
1299:         PUSH PDP,DEVDAT         ; SAVE TTY DDB ADDRESS
1300:         HLRZ DEVDAT,DEVLST      ;SEARCH ALL DDB'S
1301: DEA1:   CAIE DEVDAT,@(PDP)      ;IS THIS DEVICE NOT TO BE DEASSIGNED?
1302:         PUSHJ PDP, DEASG        ;NO, TRY TO DEASSIGN IT
1303:         JFCL                    ;IGNORE IF CAN'T
1304:         HLRZ DEVDAT, DEVSER(DEVDAT)
1305:         JUMPN DEVDAT, DEA1
1306:         POP PDP,DEVDAT          ;RESTORE TTY DDB ADDRESS
1307:         POPJ PDP,
    COMCSS page# 0031 next  prev
1309: ;ROUTINE TO READ CONSOLE AND CONVERT ANY RADIX NUMBER
1310: ; CALL: MOVE R,  DESIRED RADIX
1311: ;       PUSHJ PDP, ANYRIN
1312: ;       NO ARG. TYPED RETURN, TAC1=0
1313: ;       ILLEGAL CHARACTER RETURN
1314: ;       NORMAL EXIT     ;AC TAC1 CONTAINS NUMBER
1315: ;SCAN STOPS ON FIRST CR,DASH,SPACE,OR TAB OR ILLEGAL CHAR.
1316: ;IF IT IS ILLEGAL CHAR.,SUBROUT. LEVEL IS POPED AND COMERA IS CALLED
1317: ;WHICH PRINTS MONITOR COMMAND ERROR. THUS CALLER NEVER SEES RETURN
1318: ;SKIPS LEADING SPACES AND TABS
1319: 
1320: 
1321: 
1322: C←BUFPNT                        ;CHARACTER AC
1323: R←DSER                          ;RADIX AC
1324: 
1325: DECIN1:
1326: DECIN: MOVEI R,=10             ;DECIMAL INPUT
1327:         JRST ANYRIN
1328: 
1329: OCTINS:PUSHJ P,GETLCCHR        ;SKIP PRECEEDING + OR -
1330: OCTIN: MOVEI R,10              ;OCTAL INPUT
1331: ANYRIN: PUSHJ PDP,SKIPS1        ;SKIP LEADING SPACES, TABS, NULLS
1332:                                 ;DO NOT RETURN IF CR WAS PREVIOUS BREAK
1333:                                 ;OR THIS BREAK
1334: OCT0:   CAIL TEM,175            ; ALT MODE?
1335:         JRST CPOPJ2
1336:         CAIE TEM,";"            ;SEMICOLON?
1337:         CAIN TEM," "            ;SPACE?
1338:         JRST CPOPJ2             ;YES, SKIP RETURN
1339:         CAIE TEM,"-"            ;NO, DASH?
1340:         CAIN TEM,15             ;CR?
1341:         JRST CPOPJ2             ;YES, ONLY LEGAL TERMINATORS
1342:         CAIE TEM,","            ;COMMA?
1343:         CAIN TEM,"["            ;LEFT BRACKET?
1344:         JRST CPOPJ2             ;YES.
1345:         SUBI TEM,60
1346:         JUMPL TEM,CPOPJ1        ;ERROR IF NEG.,REMOVE SUB. RETURN AND PRINT
1347:         CAML TEM, R             ;OR .GE. RADIX
1348:         JRST CPOPJ1             ;ERROR, GREATER OR EQUAL TO RADIX
1349:         IMUL TAC1, R
1350:         ADD TAC1,TEM
1351: CONTYI:                ;PATCHED BY ONCE.
1352: XXTYI:
1353:         PUSHJ PDP,GETCHR
1354:         JRST OCT0
    COMCSS page# 0032 next  prev
1356: ;GET PROJECT-PROGRAMMER NUMBERS
1357: ;CALL:  MOVE TAC,INPUT BYTE POINTER
1358: ;       PUSHJ PDP,PJPGNO
1359: ;       ERROR RETURN
1360: ;       OK RETURN
1361: ;
1362: ;(AC2)LH ← PROJECT NUMBER
1363: ;(AC2)RH ← PROGRAMMER NUMBER
1364: 
1365: IFN FTLOGIN,<
1366: PJPGNO: PUSHJ PDP,SKIPS1        ;SKIP LEADING BLANKS.
1367:         CAIE TEM,"["            ;IS THERE A [?
1368:         POPJ PDP,               ;NO. NO PPN.
1369:         PUSHJ PDP,PJPG1         ;READ PROJ. "NUMBER".
1370:         HLL AC2,TAC1
1371:         CAIE TEM,","            ;SHOULD BE FOLLOWED BY A COMMA.
1372:         JRST PJPG2
1373:         PUSHJ PDP,PJPG1         ;NOW PROG. NO.
1374:         HLR AC2,TAC1
1375:         CAIN TEM,"]"            ; ] IS OPTIONAL.
1376:         PUSHJ PDP,GETLCCHR      ;THROW IT AWAY IF PRESENT.
1377:         JRST CPOPJ1
1378: 
1379: PJPG1:  PUSHJ PDP,CTEXT         ;SCAN NEXT THING.
1380:         JUMPE TAC1,TPOPJ        ;RETURN UPLEVEL IF NOTHING.
1381:         TLNN TAC1,7777
1382:         LSH TAC1,-14            ;JUSTIFY NOW IN CASE SKIPSB DOESN'T COME BACK
1383:         TLNN TAC1,77
1384:         LSH TAC1,-6
1385:         PUSHJ PDP,SKIPSB        ;MAKE SURE WE SEE TERMINATOR.
1386:         POPJ P,                 ;PROGRAM BUMMERS BEWARE OF UPLEVEL RETURN!
1387: 
1388: PJPG2:  CAIE TEM,12
1389:         POPJ P,
1390:         SKIPN TAC1,DSKPPN(J)    ;COPY PRG FROM APPROPRIATE PLACE
1391:         MOVE TAC1,PRJPRG(J)
1392:         HRR AC2,TAC1
1393:         JRST CPOPJ1
1394: >
    COMCSS page# 0033 next  prev
1396: ;ROUTINE TO PRINT TIME AS HOURS,MINUTES,SECONDS, AND HUNDRETHS
1397: ;FORMAT IS HHMM:SS.HH
1398: ;CALL:  MOVE TAC,TIME IN JIFFIES(60THS,50THS OR MILLISECONDS)
1399: ;       MOVE DAT,OUTPUT TEXT BYTE POINTER
1400: ;       PUSHJ PDP,PRTIME
1401: 
1402: JIFMIN←←JIFSEC*=60              ;NUMBER OF JIFFIES PER MINUTE.
1403: JIFSC2←←JIFSEC/2                ;NUMBER OF JIFFIES PER HALF SEC.
1404: 
1405: REPEAT 0,<      ;THIS ROUTINE HAS BEEN REPLACED BY ONE OF THE SAME NAME IN CLKSER
1406: 
1407: PRTIME: PUSHJ PDP,HHMM          ;DEC 3.16
1408:         JUMPE TAC,PR1           ;DO NOT PRINT HOURS OR MINUTES IF 0
1409:         PUSHJ PDP,RADX10        ;PRINT BASE 10
1410:         PUSHJ PDP,INLMES        ;PRINT COLON
1411:         ASCIZ /:/
1412: PR1:    MOVE TAC,TAC1           ;MOVE TAC,TAC1
1413:         IDIVI TAC,JIFSEC        ;JIFFIES PER SECOND
1414:         PUSHJ PDP,RADX10        ;PRINT SECONDS
1415:         PUSHJ PDP,PRPER         ;PRINT PERIOD
1416:         MOVE TAC,TAC1           ;NO OF JIFFIES(HUNDRETHS)
1417:         IMULI TAC,=100          ;CONVERT TO HUNDRETHS
1418:         IDIVI TAC,JIFSEC
1419:         CAIL TAC1,JIFSC2        ;ROUND IF GREATER THAN HALF
1420:         AOS TAC
1421:         MOVEI TEM,"0"           ;PRINT LEADING 0 IF NO.
1422:         JRST PR2                ;DEC 3.16
1423: 
1424: HHMM:   IDIVI TAC,JIFMIN        ;DEC 3.16, REST OF PAGE.
1425:         PUSH PDP,TAC1
1426:         IDIVI TAC,=60
1427:         IMULI TAC,=100
1428:         ADD TAC,TAC1
1429:         POP PDP,TAC1
1430:         POPJ PDP,
1431: 
1432: PRTIM1: PUSHJ PDP,HHMM
1433:         MOVEI TEM,"0"
1434:         CAIGE TAC,=1000
1435:         XCT TYO
1436:         CAIGE TAC,=100
1437:         XCT TYO
1438: PR2:    CAIGE TAC,=10
1439:         XCT TYO
1440:         JRST DECLF
1441: >;END REPEAT 0
    COMCSS page# 0034 next  prev
1443: SUBTTL  ERRCON  4 AUG 67
1444: 
1445: ;THESE ERROR ROUTINE PRINT "ERROR IN JOB N"
1446: ;FOLLOWED BY AN APPROPRIATE ERROR MESSAGE
1447: ;THEN THE JOB IS STOPPED AND CONSOLE IS RETURNED TO
1448: ;MONITOR COMMAND MODE
1449: 
1450: ;APR DETECTED ERRORS
1451: ;PUSHDOWN OVERFLOW,ILLEGAL MEMORY, NONEXISTENT MEMORY
1452: ;FOR WHICH THE USER IS NOT ENABLED.
1453: ;SEE APRSER TO SEE HOW APR INTERRUPTS ARE HANDLED
1454: ;CALL:  SKIPE TAC,APRERR        ;RESULT OF CONI APR,APRERR
1455: ;       PUSHJ PDP,APRILM        ;FROM CLK SERVICE ROUT.(LOWEST PRIOTITY PI)
1456: ;       RETURN TO RESCHEDULE NEW USER
1457: 
1458: APRILM:
1459:         SETZM APRERR(PID)       ; ZERO ERROR FLAG
1460:         MOVE ITEM,JOB(PID)      ; BLAME CURRENT JOB, WHOMEVER IT MAY BE
1461:         TRNN TAC,ILM            ; ILLEGAL MEMORY REFERENCE?
1462:         JRST APRNXM             ;NO
1463:         MOVE TAC,APRPC(PID)
1464:         TLNE TAC,USRMOD
1465:         JRST APRIL2
1466:         PUSHJ P,KILSPW          ; KILL HIS SPW JOB SO IT WON'T HAPPEN AGAIN
1467:         JRST APRIL1
1468: APRIL2: HRRZS TAC
1469:         CAMG TAC,USRREL(PID)    ;IS IT IN BOUNDS?
1470:         JRST APRIL1
1471:         TRNN TAC,400000
1472:         JRST APRJRS
1473:         LDB TAC1,PSEGN
1474:         JUMPE TAC1,APRJRS
1475:         HLRZ TAC1,JBTADR(TAC1)
1476:         CAILE TAC,400000(TAC1)
1477:         JRST APRJRS
1478: APRIL1: JSP TAC,ERRPNT          ;YES
1479:         ASCIZ /ILL MEM REF/
1480:         JRST APRSCD             ;PRINT LOC, THEN STOP JOB
1481: 
1482: APRJRS: JSP TAC,ERRPNT
1483:         ASCIZ /PC EXCEEDS MEM BOUND/
1484:         JRST APRSCD             ;PRINT LOC, THEN STOP JOB
    COMCSS page# 0035 next  prev
1486: APRNXM: TRNN TAC,NXM            ;NON-EX MEM?
1487:         JRST PDLAPR             ;NO
1488:         JSP TAC,ERRPNT          ;YES
1489:         ASCIZ /NON EX MEM/
1490:         JRST APRSCD             ;PRINT LOC, THEN STOP JOB
1491: 
1492: PDLAPR: TRNN TAC,POV            ;PUSHDOWN OVERFLOW?
1493:         JRST APRCNS             ;NO     ;JS
1494:         JSP TAC,ERRPNT          ;YES
1495:         ASCIZ /PDL OV/
1496: APRSCD: MOVE TAC1,APRPC(PID)    ;PRINT APR PC 
1497:         JRST PCPNT              ;AS:
1498:                                 ;1)"AT USER LOC XXX" OR
1499:                                 ;2)"AT EXEC LOC XXX; EXEC CALLED FROM
1500:                                 ;   EXEC/USER LOC YYY
1501: 
1502: APRCNS: TRNN TAC,CNS            ;JS, REST OF PAGE.  CONS TRAP?
1503:         JSP DAT,UERROR          ;NO. HARDWARE PROBLEM.
1504:         JSP TAC,ERRPNT
1505:         ASCIZ /CONS TRAP/
1506:         JRST APRSCD
1507: ;JS REST OF PAGE                        ;REG
    COMCSS page# 0036 next  prev
1509: ; ROUTINE TO PRINT ERROR MESSAGE FOR SPW MODULES
1510: 
1511: SPWMES:
1512:         JSP TAC,ERRPNT
1513:         ASCIZ /SPACEWAR LOSSAGE/
1514:         MOVE TAC,JBTST2(J)              ;GET GOOD BITS
1515:         TLNN TAC,ILMSPW                 ;ILL MEM REF?
1516:         JRST SPWNXM                     ;NO
1517:         HRRZS TAC
1518:         HLRZ TAC1,JBTADR(J)
1519:         CAMG TAC,TAC1
1520:         JRST SPWILM
1521:         TRNN TAC,400000
1522:         JRST SPWIPC
1523:         LDB TAC1,PSEGN
1524:         JUMPE TAC1,SPWIPC
1525:         HLRZ TAC1,JBTADR(TAC1)
1526:         TRO TAC1,400000
1527:         CAMLE TAC,TAC1
1528:         JRST SPWIPC
1529: SPWILM: PUSHJ P,INLMES
1530:         ASCIZ/ - ILL MEM REF/
1531:         JRST SPWMS1
1532: SPWIPC: PUSHJ P,INLMES
1533:         ASCIZ/ - PC EXCEEDS MEM BOUNDS/
1534:         JRST SPWMS1
1535: SPWNXM: TLNN TAC,NXMSPW
1536:         JRST SPWPDL
1537:         PUSHJ P,INLMES
1538:         ASCIZ/ - NON EX MEM/
1539:         JRST SPWMS1
1540: SPWPDL: TLNN TAC,POVSPW
1541:         JRST SPWCNS
1542:         PUSHJ P,INLMES
1543:         ASCIZ/ - PDL OV/
1544:         JRST SPWMS1
1545: SPWCNS: TLNN TAC,CNSSPW
1546:         JRST SPWTMX
1547:         PUSHJ P,INLMES
1548:         ASCIZ/ - CONS TRAP/
1549: SPWTMX: TLNN TAC,ILLTMO
1550:         JRST SPWMS1
1551:         PUSHJ P,INLMES
1552:         ASCIZ/ - TIME OUT/
1553: SPWMS1:
1554:         HRRZ TAC1,JBTST2(ITEM)
1555:         HRLI TAC1,USRMOD
1556:         PUSHJ PDP,KILSPW
1557:         JRST PCPNT
    COMCSS page# 0037 next  prev
1559: ;ADDRESS CHECK ERROR AT ANY LEVEL
1560: ;DEVDAT MUST BE SET UP TO POINT TO OFFENDING DEVICE
1561: 
1562: 
1563: ADRERR:
1564:         JSP TAC,ERRDEV          ; GET JOB NO. FROM DEVICE DATA BLOCK
1565: UADER1: ASCIZ /ADDRESS CHECK FOR /
1566:         JRST DEVEXC             ;PRINT "DEVICE XXX; EXEC CALLED FROM
1567:                                 ;   EXEC/USER LOC YYY"
1568:                                 ;THEN STOP JOB
1569: 
1570: UADRER:
1571:         MOVEI TAC,UADER1        ;ADDRESS CHECK AT UUO LEVEL.
1572:         JRST ERRPTU             ;WE WILL RETURN TO UADER1.
1573: 
1574: ; ROUTINE TO PRINT OUT MESSAGE FOR NON-IO UUOS
1575: ; CALL BY <JRST UADERR>, DOES NOT RETURN
1576: 
1577: UADERR:
1578:         JSP TAC,UUOMES
1579:         ASCIZ /ADDRESS OUT OF BOUNDS, UUO /
    COMCSS page# 0038 next  prev
1581: ;CALL:  JSP DAT,ERROR
1582: ;
1583: ;TYPES "ERROR IN MONITOR" FOLLOWED BY CONTENTS OF DAT
1584: ;THEN GOES TO AUTOLOAD
1585: 
1586: 
1587: 
1588: ERROR:
1589:         MOVEM P,ERRPDL(PID)     ;SAVE IT WHERE WE CAN FIND IT
1590:         MOVE P,ERRPD(PID)
1591:         AOBJN P,.+1
1592:         PUSHACS
1593:         PUSH P,DAT              ;SAVE CALLING ADDR
1594:         PUSHJ P,DISDATE
1595:         PUSHJ P,DISMES
1596:         ASCIZ /πππERROR IN MONITOR AT /
1597:         POP P,TAC
1598:         SUBI TAC,1
1599:         PUSHJ P,DISOCT
1600:         PUSHJ P,DISMES
1601:         ASCIZ/
1602: /
1603:         SETOM DISFLAG
1604:         PUSHJ P,DISFLUSH
1605:         POPACS
1606:         DEBCHECK
1607:         JRST AUTOLOAD           ;THIS IS A LOSE ALWAYS NOW
    COMCSS page# 0039 next  prev
1609: ; UERROR IS FOR UUO LEVEL, BLAMES CURRENT JOB
1610: ; CERROR IS FOR CLOCK LEVEL AND LOSES
1611: 
1612: UERROR:
1613:         MOVE ITEM,JOB(PID)      ; PRINT FOR CURRENT JOB NUMBER
1614: CERROR:
1615:         JSP TAC,ERRPNT          ; ITEM ALREADY SET UP
1616:         ASCIZ /?
1617: ERROR IN MONITOR/
1618:         MOVE TAC1,-1(PDP)       ;GET LOC OF JSP DAT,ERROR
1619:         JRST PCPNT              ;PRINT "AT EXEC LOC XXX;
1620:                                 ;  EXEC CALLED FROM EXEC/USER YYY"
1621:                                 ;THEN STOP JOB
1622: 
1623: ;INPUT UUO FOR OUTPUT DEVICE
1624: ;CALLED AT UUO LEVEL ONLY
1625: 
1626: 
1627: ILLINP:
1628:         JSP TAC,ERRPTU
1629:         ASCIZ /OUTPUT /
1630:         PUSHJ PDP,ERNAM         ;PRINT "DEVICE XXX"
1631:         JSP TAC,UUOMES          ;PRINT MESSAGE,UUOPC,STOP JOB
1632:         ASCIZ / CANNOT DO INPUT/
    COMCSS page# 0040 next  prev
1634: ; USER TRIED TO GIVE LPT OR PTP A BUFFER LARGER THAN
1635: ; THE INTERNAL SYSTEM BUFFER
1636: ; CALLED FROM UUO LEVEL ONLY
1637: 
1638: BTLERR:
1639:         JSP TAC,ERRPTU          ; SET UP TTY DEVDAT
1640:         ASCIZ /?
1641: /
1642:         PUSHJ PDP,ERNAM         ; "DEVICE XXX"
1643:         JSP TAC,UUOMES
1644:         ASCIZ / BUFFER TOO LARGE, UUO/
1645: 
1646: ;OUTPUT UUO FOR INPUT DEVICE
1647: ;CALLED AT UUO LEVEL ONLY
1648: 
1649: 
1650: ILLOUT:
1651:         JSP TAC,ERRPTU
1652:         ASCIZ /INPUT /
1653:         PUSHJ PDP,ERNAM         ;PRINT "DEVICE XXX"
1654:         JSP TAC,UUOMES          ;PRINT MESSAGE,UUOPC,STOP JOB
1655:         ASCIZ / CANNOT DO OUTPUT/
1656: 
1657: ;ILLEGAL DEVICE DATA MODE (INIT, OPEN, OR SETSTS UUOS)
1658: ;CALLED AT UUO LEVEL ONLY
1659: 
1660: 
1661: ILLMOD:
1662:         JSP TAC,ERRPTU
1663:         ASCIZ /ILLEGAL DATA MODE FOR /
1664:         JRST DEVEXC             ;PRINT "DEVICE XXX",UUO PC
1665: 
1666: ;IO UUO TO USER CHANNEL WITH NO PREVIOUS INIT OR OPEN
1667: ;CALLED AT UUO LEVEL ONLY
1668: 
1669: 
1670: IOIERR:
1671:         JSP TAC,ERRPTU
1672:         ASCIZ /IO TO UNASSIGNED CHANNEL/
1673:         JRST UUOPCP             ;PRINT UUO PC
    COMCSS page# 0041 next  prev
1675: ;UUOERR: ILLEGAL UUO 
1676: ;CALLED AT UUO LEVEL ONLY - liar!
1677: 
1678: 
1679: UUOERR:
1680:         SKIPE   SPWUUF(PID)     ;DON'T GIVE MESSAGE IN SPACEWAR MODE
1681:         CONSZ   PI,77000        ;YES, CH7?
1682:         CAIA                    ;NO TO EITHER
1683:         JRST    SPWERR          ;WE MIGHT BE ON THE PDP-6
1684:         MOVEM   J,TSAVJ#        ;I HATE VARIABLES, BUT SAVE J
1685:         MOVE    J,JOB(PID)      ;SOMETIMES NOT SET UP BY DPYSER
1686:         MOVE    TAC1,UUOPC(J)
1687:         JUMPE   J,UUOER3
1688:         TLNE    TAC1,USRMOD
1689:         JRST    UUOER1          ;USER MODE CALL
1690: UUOER3: MOVEM   P,ERRPDL        ;UUO CALLED FROM EXEC STORE LOSER'S P.
1691:         MOVE    P,ERRPD(PID)
1692:         ADD     P,[1,,1]
1693: UUOER1: JSP     TAC,ERRPTU      ;RETURNS WITH DAT AND DDB PUSHED
1694:         ASCIZ   /ILLEGAL UUO/
1695:         MOVE    TAC1,UUOPC(J)   ;GET LAST UUO PC
1696:         TLNE    TAC1,USRMOD     ;USER ERROR?
1697:         SOJA    TAC1,PCPNT
1698:         PUSHACS
1699:         PUSHJ   P,DISDATE
1700:         PUSHJ   P,DISMES
1701:         ASCIZ   /ππππILLEGAL UUO FROM EXEC AT UUO LEVEL
1702: UUO AT /
1703:         MOVE    TAC,UUOPC(J)
1704:         MOVEI   TAC,-1(TAC)
1705:         PUSHJ   P,DISOCT
1706:         PUSHJ   P,DISTAB
1707:         PUSHJ   P,DISJOB
1708:         PUSHJ   P,DISMES
1709:         ASCIZ   / UUOOPC = /
1710:         MOVE    TAC,UUOOPC(J)
1711:         PUSHJ   P,DISOCT
1712:         PUSHJ   P,DISMES
1713:         ASCIZ   /  P= /
1714:         MOVE    TAC,ERRPDL
1715:         PUSHJ   P,DISOCT
1716:         CAMN    J,TSAVJ
1717:         JRST    UUOER2
1718:         PUSHJ   P,DISMES
1719:         ASCIZ   /J WAS: /
1720:         MOVE    TAC,TSAVJ
1721:         PUSHJ   P,DISOCT                ;ONLY MAKES SENSE IN DECIMAL IF A JOB NUMBR
1722: UUOER2: PUSHJ   P,DISMES
1723:         ASCIZ   /
1724: FIND A WIZARD OR TYPE: POPJ 3,$X
1725: /
1726:         PUSHJ   P,SYSFIX
1727:         JFCL                    ;NO ERRORS
1728:         JFCL                    ;FOUND TROUBLE, BUT COULDN'T FIX IT!
1729:         PUSHJ   P,DISFLUSH      ;TELL THE WORLD
1730:         POPACS
1731:         PUSHJ   P,DDTCALL
1732:         MOVE    TAC1,UUOPC(J)
1733:         SOJA    TAC1,PCPNT      ;ALWAYS TRY JUST FLUSHING LOSER
    COMCSS page# 0042 next  prev
1735: ;ILLEGAL INSTRUCTION  -  ILLINS, HALT
1736: ;HALT INSTRUCTION IS A SPECIAL CASE WHICH STOPS JOB BUT
1737: ;THE USER MAY CONTINUE FROM IT(EFFECTIVE ADR.)
1738: ;CALLED AT UUO LEVEL WITH A JRST
1739: 
1740: 
1741: ILLINS:
1742:         HLRZ TAC,UUO            ; ILLEGAL OPCODE
1743:         ANDI TAC,777600         ;LOOK AT OPCODE AND HIGH 2 AC BITS
1744:         CAIN TAC,(<JRST 4,>)    ;IS IT A HALT?
1745:         JRST HALT               ;YES, PRINT DIFFERENT MESSAGE
1746:         JSP TAC,ERRPTU
1747:         ASCIZ /ILL INST./
1748:         JRST UUOPCP             ;PRINT UUO PC AND STOP JOB
1749: 
1750: HALT:  MOVE J,JOB(PID)         ; PICK UP JOB NUMBER
1751:         PUSHJ P,TTYERP          ; SET TTY IN MONITOR MODE
1752:         PUSHJ P,INLMES
1753:         ASCIZ /HALT/
1754:         SOS TAC1,UUOPC(J)       ;UUOPC = LOCATION OF HALT PLUS ONE
1755:         PUSHJ P,PCP             ;PRINT "USER LOC XXX"
1756:         PUSHJ P,PRCRCC          ;PRINT MONITOR MODE RESPONSE
1757:         HRRM UUO,UUOPC(J)       ; SAVE EFFECTIVE ADDRESS OF HALT
1758:         PUSHJ P,TTYSTC          ;START TTY TYPING
1759:         PUSHJ P,SETSTP          ;STOP JOB, BUT FINISH THIS UUO
1760:         SKIPN INTACT(PID)
1761:         JRST USRXIT             ;"RETURN" TO ADDRESS OF HALT (WILL NEVER GET THERE)
1762:         JRST ESTOP
    COMCSS page# 0043 next  prev
1764: ;ROUTINE FOR HUNG IO DEVICE
1765: ;CALL   MOVE DEVDAT,ADDRESS OF DEVICE DATA BLOCK
1766: ;       PUSHJ PDP,DEVHNG
1767: 
1768: 
1769: DEVHNG:
1770:         MOVEI TAC,IOACT         ; TURN OFF IO DEVICE ACTIVE BIT IN
1771:         ANDCAM TAC,DEVIOS(DEVDAT);MEMORY AND IOS
1772:         TRZ IOS,IOACT
1773:         JSP TAC,ERRDEV
1774:         ASCIZ /HUNG /
1775:         JRST DEVEXC
1776: 
1777: ;BAD DECTAPE DIRECTORY
1778: ;CALLED AT INTERRUPT AND UUO LEVELS WITH DEVDAT AND ITEM SETUP
1779: 
1780: 
1781: BADDIR:
1782:         JSP TAC,ERRPNT
1783:         ASCIZ /BAD DIRECTORY FOR /
1784: 
1785: ;ROUTINE TO PRINT "DEVICE XXX; EXEC CALLED FOR EXEC/USER YYY"
1786: ;THEN STOP JOB
1787: ;TO BE USED BY DEVICE DEPENDENT ERROR MESSAGES AFTER JSP TAC,DEVERR
1788: 
1789: 
1790: DEVEXC:
1791:         PUSHJ PDP,ERNAM         ; PRINT "DEVICE XXX"
1792:         MOVE TAC,(P)            ; GET DEVICE DDB
1793:         MOVE TAC1,DEVMOD(TAC)   ;RPH PATCH TO CLEAR GOBIT ON DISK ERRORS
1794:         TLNN TAC1,DVDSK
1795:         JRST EXCALP
1796:         MOVSI IOS,GOBIT
1797:         ANDCAB IOS,DEVIOS(TAC)  ;CLEAR GO BIT IF STOPPING DISK
1798:         JRST EXCALP             ;PRINT "EXEC CALLED FROM EXEC/USER LOC YYY"
    COMCSS page# 0044 next  prev
1800: ;ROUTINE TO HALT A JOB WHEN A DEVICE IS NOT READY FOR I/O
1801: ;CALLED FROM XXXSER AT UUO LEVEL
1802: ;CALL   MOVE DEVDAT,ADDR OF DEVICE DDB
1803: ;       MOVE ITEM,JOB NUMBER
1804: ;       PUSHJ PDP,HNGSTP
1805: 
1806: 
1807: HNGSTP:
1808:         PUSH PDP,IOS            ; SAVE STUFF FOR DEVICE
1809:         PUSH PDP,DEVDAT
1810:         PUSHJ PDP,TTYFUW
1811:         PUSHJ PDP,PRQM
1812:         PUSHJ PDP,ERNAM         ;PRINT "DEVICE XXX"
1813:         PUSHJ PDP,INLMES        ;AND MESSAGE
1814: ASCIZ / OK?
1815: /
1816:         PUSHJ P,PRCRCC
1817:         PUSHJ PDP,TTYSTC        ;START TTY IN COMMAND MODE
1818:         POP PDP,DEVDAT
1819:         POP PDP,IOS
1820:         PUSHJ PDP,STOP1         ;STOP JOB
1821:         JRST WSCHED             ;AND RESCHEDULE
    COMCSS page# 0045 next  prev
1823: ; ROUTINE TO PRINT A MESSAGE AND STOP A JOB IN A WAY
1824: ; THAT CAN BE CONTINUED FROM.
1825: ; CALLING . . .
1826: ;       MOVEI TAC,[ASCIZ /MESSAGE HERE/]
1827: ;       PUSHJ P,HNGMES
1828: 
1829: HNGMES:
1830:         PUSH P,IOS
1831:         PUSH P,DEVDAT
1832:         PUSH P,AC1
1833:         PUSH P,AC2
1834:         PUSH P,AC3
1835:         PUSH P,DAT
1836:         PUSH P,TEM
1837:         PUSH P,TAC1
1838:         PUSH P,TAC
1839:         MOVE J,JOB(PID)
1840:         PUSHJ P,TTYFUW
1841:         POP P,TAC
1842:         PUSHJ P,CONMES
1843:         PUSHJ P,PRCRCC
1844:         PUSHJ P,TTYSTC
1845:         PUSHJ P,STOP1
1846:         POP P,TAC1
1847:         POP P,TEM
1848:         POP P,DAT
1849:         POP P,AC3
1850:         POP P,AC2
1851:         POP P,AC1
1852:         POP P,DEVDAT
1853:         POP P,IOS
1854:         JRST WSCHED
    COMCSS page# 0046 next  prev
1856: ;COMMON ERROR MESSAGE SETUP ROUTINES - ERRPTU
1857: ;CALL:  JSP TAC,ERRPTU, ERRDEV, OR ERRPNT
1858: ;       ASCIZ /MESSAGE/
1859: ;       RETURNS HERE WITH DEVDAT SAVED 0(PDP)
1860: ;       C(DEVDAT)=TTYDDB, DAT TO TTY OUTPUT BUFFER POINTER
1861: ;       ITEM=JOB NUMBER
1862: 
1863: ;USE ERRPTU IF AT UUO LEVEL FOR SURE
1864: ;ERRDEV IF ERROR FOR AN ASSIGNED DEVICE AT ANY LEVEL
1865: ;ERRPNT WITH ITEM ALREADY SET TO OFFENDING JOB NUMBER
1866: ;THE JSP CALL IS USED IN CASE PUSHDOWN SPACE BECOMES CRITICAL
1867: ;AGAIN AND ERRPNT HAS TO WIPE EXISTING LIST OUT
1868: 
1869: ERRPTU:
1870:         SKIPN J,JOB(PID)        ; BLAME CURRENT JOB IF NOT 0
1871: ERRDEV:
1872:         LDB J,PJOBN             ; JOB NUMBER FROM DEVICE DATA BLOCK
1873: ERRPNT:
1874:         JUMPN J,.+2
1875:         SETOM NULBAD(PID)
1876:         PUSH P,DAT              ; SAVE CALL TO ERROR
1877:         SKIPL J
1878:         CAIL J,JOBN             ;REASONABLE JOB NUMBER?
1879:         CAIA
1880:         JRST ERRZZ2
1881:         PUSHACS
1882:         PUSHJ P,DISDATE
1883:         PUSHJ P,DISMES
1884:         ASCIZ/ππππERRPTU CALLED WHEN NULL JOB RUNNING
1885: /
1886:         POPACS
1887:         DEBCHECK
1888:         SKIPN DISFLAG
1889:         JRST ERRZZ2
1890:         PUSHJ P,DISFLUSH
1891:         JRST AUTOLOAD
1892: 
1893: ERRZZ2: PUSH P,DDB              ;SAVE ADR. OF DEV. DATA BLOCK
1894:         PUSH P,TAC              ;SAVE RETURN FROM ERRPNT
1895:         MOVE JDAT,JBTDAT(J)     ;EVEN NULL JOB HAS JOB DATA AREA
1896: IFN JDMPRG,<
1897:         MOVE PROG,JBTADR(J)     ;JOB RELOCATION
1898: >
1899:         PUSHJ P,TTYERP          ;FIND JOB'S TTY AND SET UP DDB.
1900:         PUSHJ P,INLMES
1901:         ASCIZ /?
1902: ERROR IN JOB /
1903:         PUSHJ P,PJOB            ;PRINT JOB NO.
1904:         JRST INLMES             ;PRINT MESSAGE SPECIFIED BY CALLER
    COMCSS page# 0047 next  prev
1906: ;ROUTINE TO PRINT UUO PC AND STOP JOB - UUOMES, UUOPCP, PCPNT
1907: ;IF IN USER MODE PC WILL PRINT AS "AT USER LOC XXX"
1908: ;IF IN EXEC MODE "AT EXEC LOC XXX; EXEC CALLED FORM EXEC/USER/ LOC YYY
1909: 
1910: 
1911: UUOMES:
1912:         MOVE J,JOB(PID)         ;MAKE SURE J IS SET UP
1913:         SKIPE SPWUUF(PID)
1914:         CONSZ PI,77000
1915:         CAIA
1916:         JRST SPWERR             ;MIGHT BE ON PDP-6
1917:         PUSH P,TAC
1918:         PUSHJ P,TTYERP
1919:         POP P,TAC
1920:         PUSHJ P,CONMES          ; PRINT MESSAGE POINTED TO BY TAC
1921: UUOPCP:
1922:         MOVE TAC1,UUOPC(J)      ; UUO PC STORED AT BOTTOM OF PDL
1923:                                 ;FIRST LOC ON PD LIST
1924:         SOJA TAC1,PCPNT         ;DECREMENT TO POINT TO UUO IN USER AREA
1925: 
1926: ;ROUTINE TO PRINT ONE OF THREE MESSAGES AND STOP JOB
1927: ;1) "AT EXEC LOC XXX; EXEC CALLED FROM EXEC LOC YYY"
1928: ;2) "AT EXEC LOC XXX; EXEC CALLED FORM USER LOC YYY"
1929: ;3) "AT USER LOC YYY"
1930: 
1931: ;CALL:  MOVE TAC1, XXX          ;WITH PC FLAGS IN LH
1932: ;       PUSHJ PDP,PCPNT
1933: ;       NEVER RETURN IF AT UUO LEVEL
1934: 
1935: 
1936: PCPNT: PUSHJ P,PCP             ;PRINT " AT EXEC XXX" OR " AT USER "
1937:         TLNE TAC1,USRMOD        ;WAS PC IN USER MODE?
1938:         JRST PCSTOP             ;YES, ENOUGH INFO.
    COMCSS page# 0048 next  prev
1940: ;ROUTINE TO PRINT EITHER: - PCSTOP, PCP
1941: ;1) "; EXEC CALLED FROM EXEC LOC YYY"
1942: ;2) "; EXEC CALLED FROM USER LOC YYY"
1943: ;AND STOP JOB
1944: ;CALL:  PUSHJ PDP,EXCALP
1945: ;       NEVER RETURNS IF AT UUO LEVEL
1946: 
1947: 
1948: EXCALP:
1949:         PUSHJ P,INLMES
1950:         ASCIZ /; UUO/
1951:         MOVE TAC1,UUOPC(J)      ; UUO PC ON PDL
1952:         SUBI TAC1,1             ;BACK IT UP TO POINT TO UUO
1953:         PUSHJ P,PCP             ;PRINT "EXEC LOC " OR USER LOC
1954: PCSTOP:
1955:         PUSHJ P,HOLD            ; STOP JOB, START TTY AND SET JOB ERROR BIT
1956:         POP P,DDB               ;RETURN ONLY IF AT INTERRUPT LEVEL
1957:         JRST TPOPJ              ;REMOVE ERROR CALL AND RETURN
1958: 
1959: ;ROUTINE TO PRINT PC AS:
1960: ;1) "EXEC LOC XXX" OR "USER LOC XXX"
1961: ;CALL:  MOVE TAC1,PC TO PRINT(LH=PC FLAGS)
1962: ;       PUSHJ PDP,PCP
1963: 
1964: 
1965: XMODE:  ASCIZ / AT EXEC /
1966: UMODE:  ASCIZ / AT USER /
1967: 
1968: PCP:    MOVEI TAC,XMODE         ;ASSUME PC IN EXEC MODE
1969:         TLNE TAC1,USRMOD        ;IS IT?
1970:         MOVEI TAC,UMODE         ;NO, USER MODE
1971:         PUSHJ PDP,CONMES        ;PRINT ONE OR OTHER
1972:         HRRZ TAC,TAC1           ;PRINT RIGHT HALF IN OCTAL
1973:                                 ;FALL INTO OCTPNT
    COMCSS page# 0049 next  prev
1975: ;ROUTINE TO PRINT 36 BIT OCTAL NO
1976: ;CALL:  MOVE DAT, TTY OUTPUT BYTE POINTER
1977: ;       MOVE TAC,OCTAL NO
1978: ;       PUSHJ PDP,OCTPNT
1979: 
1980: 
1981: OCTPNT:
1982:         PUSH    P,TAC1          ; SAVE TAC1
1983:         MOVEI   TAC1,10         ;OCTAL BASE
1984: ANYRDX: PUSH    P,ITEM
1985:         MOVEI   ITEM,(TAC1)
1986:         PUSHJ   P,OCTP1
1987:         POP     P,ITEM
1988:         POP     P,TAC1
1989:         POPJ    P,
1990: 
1991: OCTP1:  IDIV    TAC,ITEM
1992:         HRLM    TAC1,(P)
1993:         JUMPE   TAC,.+2
1994:         PUSHJ   P,OCTP1
1995:         HLRZ    TEM,(P)
1996:         MOVEI   TEM,"0"(TEM)
1997:         XCT     TYO
1998:         POPJ    P,
1999: 
2000: ;ROUTINE TO PRINT DECIMAL NO.
2001: ;CALL:  SAME AS OCTPNT
2002: ;TAC1 IS PRESERVED
2003: 
2004: RADX10:
2005:         PUSH    P,TAC1          ; OUTPUT DECIMAL
2006:         MOVEI   TAC1,12
2007:         JRST    ANYRDX
    COMCSS page# 0050 next  prev
2009: ;ROUTINE TO PRINT "DEVICE XXX"
2010: ;CALL   MOVE DAT,ASCII OUTPUT BYTE POINTER
2011: ;       PUSH PDP,DEVDAT
2012: ;       PUSHJ PDP,ERNAM
2013: 
2014: 
2015: ERNAM: PUSHJ   P,INLMES
2016:         ASCIZ   /DEVICE /
2017:         SKIPE   TAC1,-1(P)              ;IS DEVDAT = 0?
2018:         MOVE    TAC1,DEVNAM(TAC1)       ;NO, GET DEVICE NAME
2019: 
2020: 
2021: ;ROUTINE TO PRINT SIXBIT NAME
2022: ;CALL   MOVE DAT,ASCII OUTPUT BYTE POINTER
2023: ;       MOVE TAC1,NAME
2024: ;       PUSHJ PDP,PRNAME
2025: 
2026: PRNAME:
2027:         JUMPE   TAC1,CPOPJ      ;DONE IF NULL
2028:         MOVEI   TAC,0
2029:         LSHC    TAC,6           ;SHIFT IN NEXT CHAR.
2030:         MOVEI   TEM,40(TAC)
2031:         XCT     TYO             ;TYPE OUT IN ASCII.
2032:         JRST    PRNAME
    COMCSS page# 0051 next  prev
2034: ; ROUTINE TO TYPE OUT DISASTER BUFFER ON CTY AT CLOCK LEVEL
2035: ; RECCOMMENDED CALLING . . .
2036: ;       MOVE TAC,DISPTR
2037: ;       CAME TAC,DISOPT
2038: ;       PUSHJ P,DISOUT
2039: ; PUTS AS MUCH TEXT AS IT CAN INTO THE CTY OUTPUT BUFFER AND INITIATES
2040: ; CTYTYO.
2041: 
2042: DISOUT:
2043:         SETZ J,
2044:         PUSHJ P,TTYFND          ; SET UP DDB AND DAT TO THE CTY
2045: DISOU1: MOVE TAC,FCTR(DAT)      ; HOW FULL IS THE BUFFER?
2046:         CAIG TAC,1
2047:         JRST TYPGO              ; FULL TO THE GILLS. INITIATE TYPEOUT
2048:         ILDB TEM,DISOPT         ; THERE IS ROOM. PICK UP A CHARACTER.
2049:         AOS DISCTR
2050:         XCT TYO
2051:         MOVE TAC,DISOPT
2052:         MOVE AC1,TAC
2053:         IBP AC1
2054:         HRRZS AC1
2055:         CAIGE AC1,DISBUF+DISLEN
2056:         JRST DISOU2
2057:         MOVEI AC1,DISBUF-1      ; WRAP POINTER AROUND
2058:         HRRM AC1,DISOPT
2059: DISOU2: CAME TAC,DISPTR
2060:         JRST DISOU1             ; BUFFER NOT EMPTY. TRY TO STUFF ANOTHER CHARACTER IN.
2061:         JRST TYPGO              ; EMPTY. INITIATE TYPEOUT.
    COMCSS page# 0052 next  prev
2063: ; ROUTINE TO CALL WITH PIS OFF TO FINISH FLUSHING
2064: ; DISASTER BUFFER. SERVOS CTY ALL BY ITSELF
2065: ; CALLING . . .
2066: ;       PUSHJ P,DISFLUSH
2067: 
2068: DISFLUSH:
2069:         CONSO APR,MAOFF         ;ARE WE THE PDP-6
2070:         POPJ P,                 ;YES, NOTHING TO FLUSH.
2071:         CONI CTY,AC1
2072:         HRLM AC1,(P)            ;SAVE PI CHANNEL
2073:         CONO CTY,0              ;AND SET TO 0 SO WE WON'T INT
2074:         MOVEI AC1,100000        ; WAIT FOR THE CTY TO COOL OFF
2075:         SOJG AC1,.
2076:         SKIPN DAT,TTYTAB+TCONLN ;IS THE CTY THERE AT ALL?
2077:         JRST DISFL1             ;NO, SKIP ALL THIS CRAP
2078:         ADDI DAT,TTOBUF         ;POINT TO OUTPUT BUFFER
2079: DISFL3: MOVE TAC,TAKR(DAT)
2080:         CAMN TAC,PUTR(DAT)
2081:         JRST DISFL1             ; OUTPUT BUFFER EMPTY, EXIT
2082:         PUSHJ P,GETCHO          ; PICK UP A CHARACTER FROM THE OUTPUT BUFFER
2083:         PUSHJ P,CTYTYO          ; AND TYPE IT OUT
2084:         JRST DISFL3
2085: 
2086: DISFL1: MOVE TEM,DISOPT
2087:         SKIPLE DISCTR           ; MAY BE FULL
2088:                                 ; (BYTE POINTERS THE SAME WHEN FULL TOO)
2089:         CAME TEM,DISPTR         ; NOW IF THE SAME, THEN EMPTY
2090:         CAIA
2091:         JRST DISFLX             ;SO LEAVE
2092:         IBP TEM
2093:         HRRZS TEM
2094:         CAIGE TEM,DISBUF+DISLEN
2095:         JRST DISFL4
2096:         MOVEI TEM,DISBUF-1
2097:         HRRM TEM,DISOPT
2098: DISFL4: ILDB TEM,DISOPT         ; PICK UP A CHARACTER
2099:         AOS DISCTR
2100:         PUSHJ P,CTYTYO          ; TYPE OUT ON CTY
2101:         JRST DISFL1
2102: 
2103: DISFLX: HLRZ AC1,(P)
2104:         ANDI AC1,7      ;GET BACK OLD PI CHAN
2105:         CONO CTY,(AC1)
2106:         POPJ P,
    COMCSS page# 0053 next  prev
2108: ; THIS ROUTINE TYPES ONE CHARACTER IN TEM THROUGH
2109: ; THE DISASTER BUFFER.
2110: ; CALLING . . .
2111: ;       MOVE TEM,<CHARACTER>
2112: ;       PUSHJ P,DISTYO
2113: 
2114: DISTYO:
2115:         CONSO APR,MAOFF         ;ARE WE THE PDP-10
2116:         JRST CTYTYO             ;NO, JRST HANG THINGS UP WHILE WE TYPE
2117:         SKIPLE DISCTR           ; ANY ROOM IN BUFFER?
2118:         JRST DISTY1             ; YES, JUST PLUNK THE CHARACTER IN
2119:         SKIPN DISFLAG           ; ARE PIS OFF YET?
2120:         CONO PI,PIOFF           ; NO, TURN THEM OFF
2121:         PUSH P,TEM
2122:         PUSHJ P,DISFLUSH        ; EMPTY THE DISASTER BUFFER
2123:         POP P,TEM
2124:         SKIPN DISFLAG
2125:         CONO PI,PION
2126:         JRST DISTYO
2127: 
2128: DISTY1: SOSL DISCTR
2129:         JRST DISTY2
2130:         AOS DISCTR
2131:         JRST DISTYO
2132: 
2133: DISTY2: CONO PI,PIOFF
2134:         IDPB TEM,DISPTR
2135:         CONO PI,PION
2136:         MOVE AC1,DISPTR
2137:         IBP AC1
2138:         HRRZS AC1
2139:         CAIGE AC1,DISBUF+DISLEN
2140:         POPJ P,
2141:         CONO PI,PIOFF
2142:         MOVE AC1,DISPTR
2143:         IBP AC1
2144:         HRRZS AC1
2145:         CAIGE AC1,DISBUF+DISLEN
2146:         JRST DISTY3
2147:         MOVEI AC1,DISBUF-1
2148:         HRRM AC1,DISPTR
2149: DISTY3: CONO PI,PION
2150:         POPJ P,
    COMCSS page# 0054 next  prev
2152: ;DISMES, DISCRLF, DISTAB, DISJOB
2153: ; ROUTINE TO DO A DISASTER OUTPUT OF A STRING
2154: ; CALL BY:
2155: ;       PUSHJ P,DISMES
2156: ;       ASCIZ /<STRING>/
2157: 
2158: DISMES:
2159:         POP     P,AC1           ;GET RETURN ADDRESS
2160:         HRLI    AC1,(<POINT 7,0>)
2161: DISME1: ILDB    TEM,AC1
2162:         JUMPE   TEM,1(AC1)      ; END OF STRING. RETURN
2163:         PUSH    P,AC1           ;KEEP THIS SAFE FROM TIGERS
2164:         PUSHJ   P,DISTYO
2165:         POP     P,AC1
2166:         JRST    DISME1
2167: 
2168: 
2169: DISCRLF:                       ;CALL TO DO DISASTER OUTPUT OF CRLF ON THE CTY
2170:         MOVEI   TEM,15
2171:         PUSHJ   P,DISTYO
2172:         MOVEI   TEM,12
2173:         JRST    DISTYO
2174: 
2175: DISTAB:                        ;CALL TO DO DISASTER OUTPUT OF A TAB ON THE CTY
2176:         MOVEI   TEM,11          ;LOAD TAB
2177:         JRST    DISTYO
2178: 
2179: DISJOB:                        ;TYPE JOBNUMBER(JOBNAME). J IS SET WITH JOBNUMBER
2180:                                 ;J IS PRESERVED.
2181:         PUSH    P,J             ;SAVE JOB NUMBER
2182:         MOVE    TAC1,JOBNAM(J)  ;GET THE JOBNAME
2183:         PUSHJ   P,DISSIX
2184:         MOVEI   TEM,"("
2185:         PUSHJ   P,DISTYO
2186:         MOVE    TAC,(P)
2187:         PUSHJ   P,DISDCP        ;TYPE JOB NUMBER IN DECIMAL WITH DECIMAL POINT
2188:         MOVEI   TEM,")"
2189:         PUSHJ   P,DISTYO
2190:         POP     P,J
2191:         POPJ    P,
2192: 
    COMCSS page# 0055 next  prev
2194: ;CALLING SEQUENCE
2195: ;       PUSHJ P,DISERR
2196: ;       XWD CODE,ADDR
2197: ;       XWD CODE,ADDR
2198: ;             .
2199: ;             .
2200: ;             .
2201: ;             .
2202: ;            -1
2203: ;
2204: 
2205: DISER1: AOS (P)         ;NEXT ARG
2206: DISERR:SKIPGE TAC,@(P)
2207:         JRST CPOPJ1                     ;SKIP RETURN
2208:         ASH TAC,-=23                    ;ONLY CODE BITS PLEASE
2209:         MOVEI AC1,@(P)                  ;GET EFFECTIVE ADDRESS
2210:         MOVEI AC1,@(AC1)                ;NOW GET IT'S EFFECTIVE ADDRESS
2211:         CAILE TAC,ERRLEN-1
2212:         JRST DISER1
2213:         JRST @ERRTAB(TAC)               ;DISPATCH
2214: 
2215: DEFINE ERRMAC $ (I)
2216: <       ERR$I
2217: >
2218: ERRTAB: QQQNAM
2219: ERRLEN←←.-ERRTAB
    COMCSS page# 0056 next  prev
2221: ; HERE ARE THE VARIOUS PRINTOUT ROUTINES FOR DISERR
2222: 
2223: ERRSTR: HRLI AC1,(<POINT 7,0>)
2224: ERRST1: ILDB TEM,AC1
2225:         JUMPE TEM,DISER1        ;QUIT ON ZERO
2226:         PUSH P,AC1
2227:         PUSHJ P,DISTYO
2228:         POP P,AC1
2229:         JRST ERRST1
2230: 
2231: ERRCHR: HRRZ TEM,AC1
2232:         PUSHJ P,DISTYO
2233:         JRST DISER1
2234: 
2235: ERROCT: MOVE TAC,(AC1)
2236:         PUSHJ P,DISOCT
2237:         JRST DISER1
2238: 
2239: ERRLOC: MOVE TAC,(AC1)
2240:         PUSHJ P,DISLOC
2241:         JRST DISER1
2242: 
2243: ERRDEC: MOVE TAC,(AC1)
2244:         PUSHJ P,DISDEC
2245:         JRST DISER1
2246: 
2247: ERRSIX: MOVE TAC1,(AC1)
2248:         PUSHJ P,DISSIX
2249:         JRST DISER1
2250: 
2251: ERRDCP: MOVE TAC,(AC1)
2252:         PUSHJ P,DISDCP          ;DECIMAL WITH PERIOD
2253:         JRST DISER1
    COMCSS page# 0057 next  prev
2255: ;DISLOC PRINTS OUT 6 DIGIT OCTAL LOCATION WITHOUT LEADING ZEROES
2256: ;CALL   MOVE TAC,<LOCATION>
2257: ;       PUSHJ P,DISLOC
2258: DISLOC:
2259:         PUSH P,[=6]
2260:         HRLZ TAC1,TAC
2261: DISLC1: TLNE TAC1,700000        ;DO WE HAVE A DIGIT YET?
2262:         JRST DSOCT2             ;YES, PRINT ADDRESS
2263:         LSH TAC1,3              ;SHIFT LEFT 3 BITS
2264:         SOSLE (P)
2265:         JRST DISLC1
2266:         JRST DSOCT2             ;PRINT ONE ZERO.
2267: 
2268: ; OCTAL PRINT ROUTINE FOR DISASTER MESSAGES
2269: ; CALLING . . .
2270: ;       MOVE TAC,<NUMBER>
2271: ;       PUSHJ P,DISOCT
2272: 
2273: DISOCT:
2274:         PUSH P,[=12]
2275:         MOVE TAC1,TAC
2276: DSOCT2: SETZ TAC,
2277:         LSHC TAC,3
2278:         MOVEI TEM,"0"(TAC)
2279:         PUSH P,TAC1
2280:         PUSHJ P,DISTYO
2281:         POP P,TAC1
2282:         SOSLE (P)
2283:         JRST DSOCT2
2284:         JRST TPOPJ
2285: 
2286: ;ANOTHER OCTAL PRINT ROUTINE. PRINTS  HALFWORD COMMA COMMA HALFWORD
2287: DISOCH:
2288:         PUSH    P,TAC           ;SAVE THE ARGUMENT
2289:         HLLZ    TAC1,TAC        ;GET LEFT SIDE IN LEFT SIDE
2290:         PUSH    P,[DSOCH1]      ;"RETURN" ADDRESS
2291:         PUSH    P,[6]           ;6 CHARACTERS PLEASE
2292:         JRST    DSOCT2          ;DO IT
2293: DSOCH1: MOVEI   TEM,","
2294:         PUSHJ   P,DISTYO
2295:         MOVEI   TEM,","
2296:         PUSHJ   P,DISTYO
2297:         POP     P,TAC1
2298:         HRLZ    TAC1,TAC1
2299:         PUSH    P,[6]
2300:         JRST    DSOCT2          ;WRITE IT AND RETURN
2301: 
2302: DISDCP:PUSHJ P,DISDEC
2303:         MOVEI TEM,"."
2304:         JRST DISTYO             ;APPEND . TO DECIMAL NUMBER
2305: 
2306: DISDEC:
2307:         JUMPGE TAC,DISDC1
2308:         MOVEI TEM,"-"
2309:         PUSHJ P,DISTYO
2310: DISDC1: MOVM TAC,TAC
2311: 
2312: DISNUM: IDIVI TAC,=10
2313:         HRLM TAC1,(P)
2314:         JUMPE TAC,.+2
2315:         PUSHJ P,DISNUM
2316:         HLRZ TAC,(P)
2317:         MOVEI TEM,"0"(TAC)
2318:         JRST DISTYO
    COMCSS page# 0058 next  prev
2320: ; SIXBIT PRINT ROUTINE FOR DISASTER MESSAGES
2321: ; CALLING . . .
2322: ;       MOVE TAC1,<WORD>
2323: ;       PUSHJ P,DISSIX
2324: 
2325: DISSIX:
2326:         JUMPE TAC1,CPOPJ
2327:         SETZM TAC
2328:         ROTC TAC,6
2329:         MOVEI TEM,"A"-'A'(TAC)
2330:         PUSH P,TAC1
2331:         PUSHJ P,DISTYO
2332:         POP P,TAC1
2333:         JRST DISSIX
    COMCSS page# 0059 next  prev
2335: ; INITIALIZE ROUTINE FOR DISASTER MESSAGES . . .
2336: 
2337: DISINIT:
2338:         MOVE TAC,[POINT 7,DISBUF]
2339:         MOVEM TAC,DISPTR
2340:         MOVEM TAC,DISOPT
2341:         SETZM DISFLAG
2342:         MOVEI TAC,5*DISLEN
2343:         MOVEM TAC,DISCTR
2344:         POPJ P,
    COMCSS page# 0060 next  prev
2346: ; ROUTINE TO TYPE ON THE CTY WITH PIS OFF
2347: ; CALLING . . .
2348: ;       MOVE TEM,<CHARACTER>
2349: ;       PUSHJ P,CTYTYO
2350: ; CLOBBERS TAC AND SOME OTHERS
2351: 
2352: CTYTYO:
2353:         CONSZ CTY,40            ;HAS SOMEONE TYPED SOMETHING?
2354:         JRST CTYTY2
2355: CTYTY3:
2356:         MOVEI TAC,777777
2357:         CONSZ CTY,20
2358:         SOJG TAC,.-1
2359:         DATAO CTY,TEM
2360:         CAIE TEM,11                     ;WAS THAT A TAB?
2361:         POPJ P,
2362:         MOVEI TEM,4             ;YES, SEND 3 IDLE CHARS.
2363: TABWAT:
2364:         MOVEI TAC,777777
2365:         CONSZ CTY,20
2366:         SOJG TAC,.-1
2367:         DATAO CTY,[1]
2368:         SOJG TEM,TABWAT
2369:         POPJ P,
2370: 
2371: CTYTY2: DATAI CTY,TAC   ;YES, GET IT
2372:         CAIE TAC,"O"-100        ;IS IT ↑O?
2373:         JRST CTYTY3             ;NO, GO ON
2374:         CONSO APR,MAOFF         ;YES, ARE WE THE SIX?
2375:         POPJ P,                 ;YES, IGNORE THIS CHAR.
2376:         PUSH P,DAT              ;SAVE THIS
2377:         SKIPN DAT,TTYTAB+TCONLN ;IS THERE A CTY DDB
2378:         JRST .+3
2379:         ADDI DAT,TTOBUF
2380:         PUSHJ P,SETBFO          ;CLEAR OUTPUT BUFFER
2381:         POP P,DAT
2382:         JRST DISINI             ;CLEAR DISASTER BUFFER AND POPJ
    COMCSS page# 0061 next  prev
2384: ; ROUTINE TO SHOVE THE TIME AND DATE INTO THE BUFFER
2385: 
2386: DISDATE:
2387:         MOVEI TEM,1
2388:         PUSHJ P,DISTYO          ;WARM UP THE CTY
2389:         MOVE TAC,THSDAT
2390:         IDIVI TAC,=31
2391:         EXCH TAC,TAC1
2392:         ADDI TAC,1
2393:         PUSH P,TAC1
2394:         PUSHJ P,DISDEC
2395:         POP P,TAC1
2396:         SETZ TAC,
2397:         DIVI TAC,=12
2398:         EXCH TAC,TAC1
2399:         PUSH P,TAC1
2400:         MOVE TAC,MONTAB(TAC)
2401:         DPB TAC,[POINT 21,DISMON,27]            ;WHEW!
2402:         MOVE AC1,[POINT 7,DISMON]
2403:         MOVEI AC2,5
2404: DISDA1: ILDB TEM,AC1
2405:         PUSH P,AC1
2406:         PUSH P,AC2
2407:         PUSHJ P,DISTYO
2408:         POP P,AC2
2409:         POP P,AC1
2410:         SOJG AC2,DISDA1
2411:         POP P,TAC1
2412:         MOVEI TAC,=64(TAC1)
2413:         PUSHJ P,DISDEC
2414:         MOVEI TEM," "
2415:         PUSHJ P,DISTYO
2416:         MOVE TAC,TIME
2417:         IDIVI TAC,JIFMIN
2418:         IDIVI TAC,=60
2419:         IMULI TAC,=100
2420:         ADD TAC,TAC1
2421:         PUSHJ P,DISDEC
2422:         PUSHJ P,DISMES
2423:         ASCIZ /
2424: /
2425:         POPJ P,
    COMCSS page# 0062 next  prev
2427: SUBTTL  IOCSS   4 AUG 67
2428: 
2429: ;ROUTINE TO ADVANCE OUTPUT BUFFER AT INTERRUPT LEVEL
2430: 
2431: ;CALL:  PUSHJ PDP,ADVBFE
2432: ;       EXIT1           RETURN IF NEXT BUFFER IS EMPTY
2433: ;       EXIT2           RETURN IF NEXT BUFFER IS FULL
2434: ;CLEARS THE USE BIT (IOUSE:=0) OF THE BUFFER POINTED TO BY THE
2435: ;OUTPUT BUFFER ADDRESS (DEVOAD) OF THE CURRENT DEVICE DATA BLOCK
2436: ;AND ADVANCES THE BUFFER ADDRESS TO THE NEXT BUFFER IN THE RING.
2437: ;UPON RETURN, SKIPS IF THE NEXT BUFFER IS FULL.
2438: ;SECOND WORD OF NEXT BUFFER IS ADDRESS CHECKED TO
2439: ;MAKE SURE IT IS NOT IN JOB DATA AREA OR ABOVE USER AREA
2440: ;THE SECOND WORD OF CURRENT BUFFER WAS CHECKED AT UUO LEVEL
2441: ;OR PREVIOUS CALL TO ADVBFE
2442: 
2443: 
2444: 
2445: ADVBFE:
2446:         AOS     NABFE                   ;COUNT BUFFER ADVANCE
2447:         PUSH    P,AC3
2448:         JSP     AC3,PRSET               ;SET UP PROT-RELOC REGISTERS
2449:         SKIPN   TAC1,DEVOAD(DDB)        ;PICK UP BUFFER ADDRESS
2450:         JRST    ADVXIT                  ;NONE THERE, EXIT
2451:         JSP     AC3,ADRCK               ;MAKE SURE THIS IS A LEGAL ADDRESS
2452:         XCTR    XW,[MOVEM IOS,-1(TAC1)]
2453:         MOVSI   TAC,IOUSE
2454:         XCTR    XRW,[ANDCAB TAC,(TAC1)]
2455:         TRNE    IOS,740000              ;ANY ERRORS?
2456:         JRST    ADVXIT                  ;YES, DO NOT FILL NEXT BUFFER
2457:         MOVE    TAC1,TAC
2458:         JSP     AC3,ADRCK               ;ADDRESS CHECK NEXT BUFFER IN RING
2459:         HRRM    TAC1,DEVOAD(DDB)        ;OK. PUT IN LATEST FREE BUFFER ADDRESS
2460:         JRST    ADVBE2
2461: 
2462: ;ENTER HERE FROM SCNSER TO CHECK IF NEXT BUFFER FULL OF DATA YET
2463: 
2464: ADVBE1:
2465:         PUSH    P,AC3
2466:         JSP     AC3,PRSET
2467: ADVBE2: SKIPN   TAC1,DEVOAD(DDB)
2468:         JRST    ADVXIT
2469:         XCTR    XR,[SKIPL (TAC1)]
2470:         JRST    ADVXIT
2471:         JRST    ADVBF1
    COMCSS page# 0063 next  prev
2473: ; ROUTINE TO PUSH CURRENT PR ON STACK AND SET UP NEW PR
2474: ; CALLING . . .
2475: ;       JSP AC3,PRSET
2476: ; RETURNS WITH PR ON STACK.
2477: 
2478: PRSET:
2479: IFN FTXCTR,<PUSH P,160
2480:             PUSH P,@161>        ; MAKE XCTR SIMULATION RECURSIVE
2481:         PUSH P,AC2
2482:         PUSH P,AC1
2483:         PUSH P,J
2484:         PUSH P,TEM
2485:         PUSH P,LASTPR(PID)
2486:         LDB J,PJOBN
2487:         PUSHJ P,GETPR
2488:         MOVEM TAC,LASTPR(PID)
2489:         DATAO APR,TAC
2490:         MOVEI TEM,JOBPFI        ; SET UP ADDRESS OF JOB DATA AREA
2491:         HLRZ AC1,PROG           ; SET UP BOUNDS OF JOB FOR ADDRESS CHECKING
2492:         LDB AC2,PSEGN
2493:         JUMPE AC2,(AC3)         ; NO UPPER SEGMENT, LEAVE
2494:         HLRZ AC2,JBTADR(AC2)    ; PICK UP ITS SIZE
2495:         ADDI AC2,400000
2496:         JRST (AC3)
    COMCSS page# 0064 next  prev
2498: ; ROUTINE TO ADDRESS CHECK SOMETHING
2499: ; CALLING . . .
2500: ;       MOVE TAC1,<ADDRESS TO BE CHECKED>
2501: ;       MOVE AC1,<LOWER SEGMENT LENGTH>
2502: ;       MOVE AC2,<UPPER SEGMENT LENGTH>
2503: ;       JSP AC3,ADRCK
2504: ; GOES TO ADVXIT IF ERROR
2505: 
2506: ADRCK:  CAILE TEM,(TAC1)        ; ABOVE JOB DATA AREA?
2507:         JRST ADVXIT             ; NO, ERROR
2508:         CAIL AC1,(TAC1)         ; INSIDE LOWER?
2509:         JRST (AC3)              ; YES
2510:         TRNE TAC1,400000        ; IS IT UPPER SEGMENT ADDRESS?
2511:         CAIGE AC1,(TAC1)        ; YES, IS IT THEN IN THE UPPER SEGMENT?
2512:         JRST ADVXIT             ; NO, ERROR
2513:         JRST (AC3)              ; YES, WIN
2514: 
2515: ADVXIT: POP P,LASTPR(PID)       ; POP PR OFF STACK
2516:         DATAO APR,LASTPR(PID)   ; RESTORE PR
2517:         POP P,TEM
2518:         POP P,J
2519:         POP P,AC1
2520:         POP P,AC2
2521: IFN FTXCTR,<POP P,@161
2522:             POP P,160>          ;XCTR SIMULATION
2523:         POP P,AC3
2524:         POPJ P,
    COMCSS page# 0065 next  prev
2526: ;ROUTINE TO ADVANCE INPUT BUFFER AT INTERRUPT LEVEL
2527: 
2528: ;CALL:  PUSHJ PDP,DEVBFF
2529: ;       EXIT1           RETURN IF NEXT BUFFER IS FULL
2530: ;       EXIT2           RETURN IF NEXT BUFFER IS EMPTY
2531: ;SETS THE USE BIT (IOUSE:=1) OF THE BUFFER POINTED TO BY THE
2532: ;INPUT BUFFER ADDRESS (DEVIAD) OF THE CURRENT DEVICE DATA BLOCK
2533: ;AND ADVANCES THE BUFFER ADDRESS TO THE NEXT BUFFER IN THE RING.
2534: ;UPON RETURN, SKIPS IF THE NEXT BUFFER IS EMPTY.
2535: ;SECOND WORD OF NEXT BUFFER IS ADDRESS CHECKED TO MAKE SURE
2536: ;IT IS NOT IN IO PROTECTED PART OF JOB DATA AREA OR ABOVE
2537: ;USER AREA
2538: ;ALSO END OF BUFFER IS CHECKED TO MAKE SURE NOT ABOVE JOB AREA
2539: 
2540: 
2541: 
2542: ADVBFF:
2543:         AOS     NABFF
2544:         PUSH    P,AC3
2545:         JSP     AC3,PRSET
2546:         SKIPN   TAC1,DEVIAD(DDB)        ;IS THERE A BUFFER ADDRESS THERE?
2547:         JRST    ADVXIT                  ;NO, ERROR EXIT
2548:         JSP     AC3,ADRCK               ;YES, IS IT LEGAL
2549:         XCTR    XW,[MOVEM IOS,-1(TAC1)]
2550:         MOVSI   TAC,IOUSE
2551:         XCTR    XRW,[IORB TAC,(TAC1)]
2552:         MOVE    TAC1,TAC
2553:         JSP     AC3,ADRCK
2554:         HRRM    TAC1,DEVIAD(DDB)
2555:         XCTR    XR,[SKIPGE TAC1,(TAC1)]
2556:         JRST    ADVXIT
2557:         HLRZS   TAC1
2558:         ADD     TAC1,TAC                ;ADDRESS CHECK END OF BUFFER TOO
2559:         JSP     AC3,ADRCK
2560: ADVBF1: SKIPGE  TAC,JBTSTS(J)           ;IF JOB IS NOT RUNNING . . .
2561:         TLNE    TAC,SHF!SWP!CMWB        ;OR SWUFFLING OR SCHWAPPING . . .
2562:         JRST    ADVXIT                  ;DO NOT ALLOW THE DEVICE TO GO ON.
2563:         TRNN    IOS,IOCON+740000
2564: IFE FTXCTR,<    AOS     -6(P)>          ;NO ERRORS, GIVE SUCCESS RETURN 
2565: IFN FTXCTR,<    AOS     -10(P)>         ;2 MORE FOR 160 AND @161
2566:         JRST    ADVXIT                  ;LASTPR, TEM, J, AC1, AC2, AND AC3 ARE ON STACK
    COMCSS page# 0066 next  prev
2568: ;ROUTINE TO ADDRESS CHECK AT UUO LEVEL ONLY
2569: ;CALL   HRRZ AC1,REL ADR.
2570: ;       PUSHJ PDP,UADCK1
2571: ;       NEVER RETURNS IF ERROR,STOPS JOB AND PRINTS ERROR
2572: ;BAD ADR. IF IN LOC 20-JOBPFI IN JOB DATA AREA
2573: ;OR IF ABOVE PROTECTION(USRREL) FOR CURRENT JOB
2574: 
2575: 
2576: UUOACK:HRRZ  AC1,UUO   ;CHECK UUO.
2577: 
2578: UADCK1:
2579:         TRNN AC1,777760         ; IN USER ACS?
2580:         POPJ PDP,               ;YES, ADDRESS IS OK
    COMCSS page# 0067 next  prev
2582: ;ROUTINE TO ADDRESS CHECK AT UUO LEVEL ONLY
2583: ;USER ACS ARE ALSO ILLEGAL(ADR IS FOR IO USE LATER AT
2584: ;INTERRUPT LEVEL)
2585: ;CALL:  HRRZ AC1,REL.ADR.
2586: ;       PUSHJ PDP,UADRCK
2587: ;       NEVER RETURN IF ERROR
2588: 
2589: 
2590: UADRCK: MOVE J,JOB(PID)
2591:         CAILE AC1,JOBPFI        ;IS ADR. IN IO PROT. PART OF JOB DATA AREA?
2592:         JRST UADCK2             ;NO
2593:         PUSH P,AC1      ; SAVE OUR ACCUMULATOR
2594:         MOVE AC1,UUOPC(ITEM)
2595:         TLNE AC1,USRMOD
2596:         JRST UADRER     ; EXEC MODE IS GOD.
2597:         POP P,AC1
2598:         POPJ P,
2599: UADCK2: CAMG AC1,USRREL(PID)    ;NO, IS IT ABOVE PROTECT.?
2600:         POPJ PDP,               ;NO
2601:         TRNN AC1,400000         ; IS IT IN UPPER SEGMENT?
2602:         JRST UADRER             ; NO, MUST BE ERROR
2603:         PUSH P,AC2              ; GET US AN ACCUMULATOR
2604:         LDB AC2,PSEGN           ; PICK UP SEGMENT NUMBER
2605:         JUMPE AC2,UADRER        ; NONE IS ERROR
2606:         HLRZ AC2,JBTADR(AC2)    ; PICK UP REL. ADR.
2607:         CAILE AC1,400000(AC2)
2608:         JRST UADRER
2609:         POP P,AC2
2610:         POPJ P,
    COMCSS page# 0068 next  prev
2612: ;ROUTINE TO ADDRESS CHECK AT ANY LEVEL
2613: ;CALL:  MOVE PROG,[XWD PROT.,RELOC,]
2614: ;       HRRZ TAC,REL. ADR.
2615: ;       PUSHJ PDP,IADRCK
2616: ;       ERROR RETURN(ERROR MESSAGE NOT PRINTED,JOB NOT STOPPED)
2617: ;       OK RETURN
2618: 
2619: 
2620: IADRCK:
2621:         MOVS TAC1,PROG          ; GET PROTECTION TO RH
2622:         CAILE TAC,JOBPFI        ;ADR. ABOVE PROT. PART OF JOB DATA AREA?
2623:         CAILE TAC,(TAC1)        ;YES, BELOW OR EQUAL TO PROTECT.?
2624:         POPJ PDP,               ;NO
2625:         JRST CPOPJ1             ;YES, SKIP RETURN
    COMCSS page# 0069 next  prev
2627: ;ROUTINE TO CHECK VALIDITY OF A DUMP MODE COMMAND LIST
2628: ;WHICH IS:
2629: ;A LIST OF 0 OR MORE IOWD FORMAT WORDS
2630: ;   TERMINATED BY A GOTO WORD(LH=0)
2631: ;  WHICH POINTS TO ANOTHER LIST OF 0 OR MORE IOWD FORMAT WORDS ETC.
2632: ;   UNTIL A GOTO WORD IS ENTIRELY ZERO
2633: ;
2634: ;SINCE MONITOR DOES NOT RESCHEDULE WHEN IN EXEC MODE
2635: ;A MAXIMUM LIST OF 100 IS IMPOSED
2636: 
2637: ;CALL:  MOVE UUO,[XWD PROG,REL. ADR. OF FIRST COMMAND]
2638: ;       PUSHJ PDP,COMCHK
2639: ;       ADDRESS CHECK RETURN(ERROR ROUTINE IS NOT CALLED)
2640: ;       OK RETURN, SUM OF LH OF IOWDS IN DAT
2641: ;               ADDRESS OF FIRST IOWD (LH NOT 0) IN UUO
2642: 
2643: 
2644: COMCHK:
2645:         PUSH PDP,UUO            ;SAVE POINTER TO LIST
2646:         PUSH PDP,AC2
2647:         PUSH PDP,AC3            ;JS
2648:         MOVEI AC1,JOBPFI        ;HIGHEST IO PROTECTED LOC. IN JOB DATA AREA
2649:         MOVE AC2,UUOPC(ITEM)
2650:         TLNN AC2,USRMOD         ; IS THIS A MONITOR CALL
2651:         MOVEI AC1,JOBSAV        ;YES, HIGHEST LOC. NOT WRITTEN BY SAVE
2652:         SETZB DAT,AC2           ;CLEAR WORD COUNT AND ADDRESS OF FIRST IOWD
2653:         MOVEI ITEM,100          ;ONLY 100 LISTS
2654:         JRST COMCK1
2655: COMCK0: HRR UUO,TAC1            ;CHANGE COMMAND LIST POINTER ON GO TO WORD
2656:         CAIE AC1,JOBPFI
2657:         JRST COMCK1             ;JS
2658:         HRRZ TAC,UUO            ;CHECK JUMP ADDRESS
2659:         PUSHJ PDP,IADRCK
2660:         JRST COMCKE             ;ERROR.
    COMCSS page# 0070 next  prev
2662: COMCK1: SOJLE ITEM,COMCKE       ;EXCEEDED 100 YET?
2663:         SKIPN TAC1,@UUO         ;NO. GET NEXT IOWD. END OF LIST?
2664:         JRST COMCK2             ;YES
2665:         TLNN TAC1,777777        ;IS IT A GO TO WORD?
2666:         JRST COMCK0             ;YES
2667:         HLRO AC3,TAC1           ;NO. SAVE NEGATIVE WORD COUNT ;JS
2668:         HRRZS TAC1              ;GET LOWEST ADDRESS-1
2669:         CAMGE TAC1,AC1          ;IS IT GREATER THAN LOC. PROTECTED
2670:                                 ;FROM IO IN JOB DATA AREA?
2671:         JRST COMCKE             ;NO. ERROR RETURN
2672:         SUB TAC1,AC3            ;YES. COMPUTE LAST LOC. ;JS
2673:         CAMLE TAC1,USRREL(PID)  ;IS LAST LOC. IN BOUNDS?
2674:         JRST COMCKE             ;NO. ERROR RETURN
2675:         SUB DAT,AC3             ;YES. ACCUMULATE NEG. WORD COUNT ;JS
2676:         SKIPN AC2               ;IS THIS THE FIRST IOWD?
2677:         MOVE AC2,UUO            ;YES. SAVE ADDRESS IN AC2
2678:         AOJA UUO,COMCK1         ;GO GET NEXT IOWD
2679: 
2680: COMCK2: SKIPE AC2               ;ARE THERE ANY IOWDS WITH LH NOT 0?
2681:         MOVE UUO,AC2            ;YES, POINT UUO TO FIRST SUCH IOWD.
2682:                                 ;OTHERWISE, UUO POINTS TO A ZERO.
2683:         POP PDP,AC3             ;JS
2684:         POP PDP,AC2
2685:         JRST TPOPJ1             ;REMOVE SAVED UUO AND SKIP RETURN
2686: COMCKE: POP PDP,AC3             ;JS
2687:         POP PDP,AC2
2688:         POP PDP,UUO             ;RESTORE ORIGINAL UUO
2689:         POPJ PDP,               ;ERROR RETURN
    COMCSS page# 0071 next  prev
2691: ;ASSASG ASSIGN DEVICE IF UNASSIGNED
2692: ;CALL:  MOVE    J, JOB NUMBER
2693: ;       MOVE    DDB, ADDRESS OF DDB
2694: ;       MOVEI   TAC1, EITHER ASSPRG OR ASSCON
2695: ;       PUSHJ   P, ASSASG
2696: ;       CAN'T   ASSIGN RETURN
2697: ;       DEVICE ASSIGNED RETURN
2698: 
2699: 
2700: ASSASG:
2701:         MOVE    TAC,JBTPRV(J)
2702:         TLNE    TAC,LUPPRV              ;LOCAL USER?
2703:         JRST    ASSAS3                  ;YES. BYPASS TEST
2704:         MOVE    TAC,DEVCMR(DDB)
2705:         TLNE    TAC,DEVLUP              ;REQUIRES LOCAL USER STATUS?
2706:         POPJ    P,                      ;YES.  FAIL.
2707: ASSAS3: MOVE    TAC,DEVCMR(DDB)
2708:         TLNN    TAC,DEVSHR              ;SHARABLE DEV?
2709:         JRST    ASSAS2                  ;NO
2710:         HRRZ    TAC,DEVSER(DDB)
2711:         PUSHJ   P,DGETDD(TAC)           ;YES - MAKE A NEW DDB
2712:         JRST    ASSAS0
2713: 
2714: ASSAS2: LDB     TAC,PJOBN
2715:         CAIE    TAC,(J)                 ;IS THIS DDB OURS?
2716:         JRST    ASSAS1
2717: ;       MOVE TAC,TAC1
2718: ;       ANDI TAC,ASSPRG
2719: ;       TDNN TAC,DEVMOD(DDB)            ;ARE WE INITING AN ALREADY INITED DEVICE?
2720:         JRST    ASSAS0                  ;NO
2721:         POPJ    P,                      ;YES, LOSE
2722: 
2723: ASSAS1: MOVE    TAC,[TTYATC,,ASSCON!ASSPRG]
2724:         CONO    PI,SCNOFF               ;TURN SCANNER OFF
2725:         TDNE    TAC,DEVMOD(DDB)         ;ONE LAST CHECK
2726:         JRST    SCNONJ                  ;OOPS - EATEN AWAY FROM UNDER US
2727: ASSAS0: DPB     J,PJOBN                 ;NO, STORE JOB NUMBER
2728:         IORM    TAC1,DEVMOD(DDB)        ;SET ONE OF ASSIGN BITS
2729:         MOVSI TAC,DVTTY
2730:         TDNE TAC,DEVMOD(DDB)
2731:         JRST ASSAST                     ;JUMP IF ASSIGNING A TTY
2732: ASSASZ: CONO    PI,SCNON                ;TURN SCANNER CHAN. BACK ON
2733:         JRST    CPOPJ1
2734: 
2735: ASSAST: PUSH P,AC1
2736:         LDB TAC,PUNIT
2737:         SKIPGE TTYTAB(TAC)              ;SKIP IF COMBIT IS NOT SET
2738:         SOS COMCNT
2739:         MOVSI AC1,COMBIT+DLYBIT
2740:         ANDCAM AC1,TTYTAB(TAC)
2741:         POP P,AC1
2742:         JRST ASSASZ
    COMCSS page# 0072 next  prev
2744: ;ROUTINE TO SEARCH FOR A DEVICE
2745: ;CALL:  HRR ITEM,JOB NUMBER
2746: ;       MOVE TAC,[SIXBIT .DEVICE NAME.]
2747: ;       PUSHJ PDP, DEVSRC
2748: ;       NOT FOUND
2749: ;       FOUND
2750: 
2751:         
2752: FNDDDB:TLNE TAC,770000         ;IS IT NAME OR #?
2753:         JRST DEVSRC
2754:         CAMG TAC,USRHCU(PID)    ;LEGAL CHANNEL?
2755:         SKIPN DDB,USRJDA(TAC)   ;GET DDB POINTER
2756:         POPJ P,                 ;LOSE
2757:         JRST CPOPJ1
2758: 
2759: DEVSRC:
2760:         MOVSI DEVDAT,JLOG       ;IS JOB LOGGED IN?
2761:         TDNE DEVDAT,JBTSTS(J)
2762:                                 ;DO NOT SEARCH LOGICAL NAMES IF
2763:                                 ;FETCHING "LOGOUT" FROM "SYS".
2764:         PUSHJ PDP, DEVLG        ;SEARCH LOGICAL NAMES FIRST
2765:         JRST DEVPHY             ;NOT FOUND, SEARCH PHYSICAL NAMES
2766:         JRST CPOPJ1             ;FOUND
2767: 
2768: ;SEARCH LOGICAL NAMES
2769: 
2770: DEVLG: HLRZ DEVDAT,DEVLST      ;BEGINNING OF DDB CHAIN
2771: DEVLP0: CAME TAC,DEVLOG(DEVDAT) ;COMAPRE WITH LOGICAL NAME
2772:         JRST DEV0               ;NO MATCH
2773:         LDB TAC1,PJOBN          ;DOES THE LOGICAL NAME BELONG TO THIS JOB?
2774:         CAMN TAC1,ITEM
2775:         JUMPN TAC,CPOPJ1        ;YES, GIVE SUCCESSFUL RET. IF NAME NOT 0
2776: DEV0:   HLRZ DEVDAT,DEVSER(DEVDAT)
2777:                                 ;NO, KEEP LOOKING
2778:         JUMPN DEVDAT,DEVLP0
2779:         POPJ PDP,               ;FINISHED AND NOT FOUND
    COMCSS page# 0073 next  prev
2781: ;SEARCH PHYSICAL NAMES
2782: 
2783: DEVPHY:
2784:         CAMN TAC,[SIXBIT /OPR/] ; IS IT "OPR"?
2785:         MOVE TAC,DEVOPR         ;YES, CHANGE TO OPERATOR'S TTY
2786:         CAMN TAC,[SIXBIT /SYS/] ;IS IT "SYS"?
2787:         SKIPA TAC,SYSTAP        ;YES, CHANGE TO SYSTEM TAPE DEVICE NAME
2788:         TDZA TAC1,TAC1          ;NO, CLEAR SYSTEM TAPE FLAG
2789:         MOVEI TAC1,SYSDEV       ;YES, SET SYSTEM TAPE FLAG
2790:         HLRZ DEVDAT,DEVLST      ;SEARCH DEVICE DATA BLOCKS
2791: DEVLP1:
2792:         TLO DEVDAT,(TAC1)       ;SET SYSTEM TAPE BIT IF SEARCHING FOR SYS
2793:         CAMN TAC,DEVNAM(DEVDAT) ;MATCH OF PHYSICAL NAME?
2794:         JUMPN TAC,CPOPJ1        ;YES, GIVE OK RET. IF NAME IS NOT 0
2795: DEVLP2: HLRZ DEVDAT,DEVSER(DEVDAT)
2796:         JUMPN DEVDAT,DEVLP1
2797:         CAME TAC,[SIXBIT /TTY/] ;IS THIS PUBLIC LOGICAL NAME TTY?
2798:         JRST    DEVLP3          ;SEE IF IT'S A TTY.
2799:         PUSH PDP,DAT            ;SAVE OUTPUT BYTE POINTER(TTY) OR INIT. ARG. ADR.
2800:         PUSHJ PDP,TTYFND        ;YES, FIND TTY JOB IS ATTACHED TO
2801:         POP PDP,DAT             ;RESTORE
2802:         JRST CPOPJ1             ;AND GIVE SUCCESSFUL RETURN
2803: DEVLP3: PUSH P,TAC              ;SAVE DEVICE NAME IN CASE NOT FOUND
2804:         PUSH P,DAT              ;AND THIS IN CASE IT IS
2805:         PUSHJ P,GETDDB          ;SEE IF TTY DDB
2806:         CAIA
2807:         AOS -2(P)               ;SKIP ON SUCCESS
2808:         POP P,DAT
2809:         POP P,TAC
2810:         POPJ P,
    COMCSS page# 0074 next  prev
2812: ;ROUTINE TO SETUP N-RING IO BUFFER IN USER AREA
2813: 
2814: ;CALL:  PUSHJ PDP,BUFCLC
2815: ;       EXIT            RETURNS HERE IF MEMORY NOT EXCEEDED
2816: ; SETS UP AN N BUFFER RING FOLLOWING THE USER'S PROGRAM, WHERE N
2817: ; IS IN THE ADDRESS FIELD OF AC UUO.
2818: ; THE BUFFER RING FORMAT IS AS FOLLOWS:
2819: ;       LOCATION                LH   CONTENTS   RH
2820: ; C(JOBFF) + 1              BUFFER         C(JOBFF) +1
2821: ;    + 0(BUFFER SIZE+2)      SIZE               + 1(BUFFER SIZE+2)
2822: ; C(JOBFF) +1               BUFFER         C(JOBFF) +1
2823: ;     +1(BUFFER SIZE+2)      SIZE                + 2(BUFFER SIZE+2)
2824: ;         .             .                    .
2825: ;       .               .                    .
2826: ;       .               .                    .
2827: ; C(JOBFF) + 1          BUFFER     C(JOBFF) + 1
2828: ;    + (N-2)(BUFFER SIZE+2)  SIZE               +(N-1)(BUFFER SIZE+2)
2829: ; C(JOBFF) + 1          BUFFER     C(JOBFF) + 1
2830: ;    + (N-1)(BUFFER SIZE+2)  SIZE                  
2831: ;THEN SET       BUFPNT:=IOUSE,C(JOBFF) + 1
2832: ; AND           JOBFF:=C(JOBFF) + N(BUFFER SIZE + 2)
2833: ; BUFWRD IS RESTORED.
2834: 
2835: BUFWRD←←AC3
2836: 
2837: BUFCLC:
2838:         LDB TAC,PDVBLN
2839:                                 ; GET BUFFER SIZE IN TAC
2840: BUFCLM: PUSH PDP,BUFWRD         ; SAVE BUFWRD ON STACK
2841:         HRRZ BUFPNT,JOBFF(PROG) ; BUFPNT:= FIRST FREE USER LOC+1
2842:         ADDI BUFPNT,1
2843:         HRRZ BUFWRD,BUFPNT
2844:         HRL BUFWRD,TAC          ; PUT XWD BUFSIZ,JOBFF IN BUFWRD
2845:         ADDI TAC,2              ; ADD 2 TO BUFFER SIZE
2846:         HRRZ TAC1,UUO           ; GET NUMBER OF BUFFERS
2847:         JUMPG   TAC1,.+2        ;SKIP UNLESS NONE WERE REQUESTED. (ME 12-11-72)
2848:         MOVEI   TAC1,2          ;GIVE HIM TWO.
2849:         HRRZ AC1,TAC
2850:         IMUL AC1,TAC1
2851:         ADD AC1,BUFWRD
2852:         HRRZ AC1,AC1
2853:         CAMG AC1,USRREL(PID)    ; WILL THIS SPACE FIT IN USER CORE?
2854:         JRST BUFC1              ; YES, DO INBUF CODE
    COMCSS page# 0075 next  prev
2856: ; HERE, WE WANT TO EXPAND CORE TO FIT IN A RING OF BUFFERS
2857: 
2858:         PUSH PDP,TAC            ; NO.
2859:         PUSH PDP,UUO            ;  SO
2860:         PUSH PDP,TAC1           ;   WE
2861:         PUSH PDP,BUFPNT         ;    SAVE
2862:         PUSH PDP,BUFWRD         ;     A
2863:         PUSH PDP,DEVDAT         ;      FEW
2864:         PUSH PDP,DSER           ;       AC'S
2865:         MOVE ITEM,JOB(PID)      ;       AND DO A CORE UUO TO MAKE ROOM
2866:         MOVE TAC,AC1            ;       HOW HIGH TO TRY FOR
2867:         MOVEI UUO,UUO           ;       ..
2868:         PUSHJ PDP,UCORE         ;       TRY FOR ANOTHER K OF USER CORE
2869:         JFCL                    ;       LET ADR CHECK HAPPEN IF CAN'T DO SO
2870:         POP PDP,DSER            ;       AND
2871:         POP PDP,DEVDAT          ;      WE
2872:         POP PDP,BUFWRD          ;     RESTORE
2873:         POP PDP,BUFPNT          ;    THE
2874:         POP PDP,TAC1            ;   FEW
2875:         POP PDP,UUO             ;  AC'S
2876:         POP PDP,TAC             ; DUE TO IOWAIT
2877:                                 ; FALL INTO BUFC1
    COMCSS page# 0076 next  prev
2879: ; END OF LOOP FOR SETTING UP AN N-RING BUFFER
2880: 
2881: BUFC1:  ADD     BUFWRD,TAC      ;ADD IN LENGTH OF BUFFER, ADDR OF NEXT BUFFER
2882:         HRRZ    AC1,BUFPNT      ;IS THIS ADDR IN BOUNDS?
2883:         PUSHJ   P,UADRCK
2884:         XCTR    XW,[MOVEM BUFWRD,(BUFPNT)]      ;PUT THIS ADDRESS IN BUFFER HEADER
2885:         HRR     BUFPNT,BUFWRD
2886:         SOJG    TAC1,BUFC1              ;LOOP AROUND AND MAKE N-1 MORE BUFFERS
2887:         HRR     BUFWRD,JOBFF(PROG)      ;UPDATE THE USER'S JOBFF
2888:         ADDI    BUFWRD,1
2889:         MOVEI   AC1,-2(BUFPNT)          ;CHECK LAST ADDRESS OF HEADER
2890:         PUSHJ   P,UADRCK
2891:         SUB     BUFPNT,TAC
2892:         XCTR    XW,[MOVEM BUFWRD,(BUFPNT)]      ;LINK LAST BUFFER TO FIRST BUFFER
2893:         ADDI    BUFPNT,-1(TAC)
2894:         HRRM    BUFPNT,JOBFF(PROG)      ;UPDATE USER'S JOBFF
2895:         HRR     BUFPNT,BUFWRD           ;LOAD IN USE BIT AND ADDRESS OF FIRST BUFFER
2896:         HRLI    BUFPNT,IOUSE
2897:         POP     P,BUFWRD                ;RESTORE BUFWRD FROM STACK
2898:         POPJ    P,                      ;EXIT
    COMCSS page# 0077 next  prev
2900: ;ROUTINE TO CLEAR IO BUFFER IN USER AREA
2901: ;CALLED AT INTERRUPT AND UUO LEVEL
2902: 
2903: ;CALL:  HRRZ TAC,REL. ADR. OF 2ND WORD OF USER BUFFER
2904: ;       PUSHJ PDP,BUFCLR
2905: ;       ERROR RETURN MEMORY EXCEEDED
2906: ;       EXIT            RETURNS HERE IF MEMORY NOT EXCEEDED
2907: ; CLEARS THE WORD COUNT AND DATA AREA OF THE BUFFER WHOSE ADDRESS
2908: ; IS IN TAC 18-35.
2909: 
2910:         
2911: 
2912: BUFCLR:
2913:         PUSHJ PDP,IADRCK        ; ADDRESS IN BOUNDS?
2914:         POPJ PDP,               ;NO. ERROR RETURN
2915:         HRLI TAC,PROG           ; SET TO RELOCATE BY PROG
2916:         PUSH PDP,TAC            ;SAVE FIRST BUFFER ADR.
2917:         HLRZ TAC1,@TAC          ;TAC1 18-35=SIZE
2918:         TRZ TAC1,400000
2919:         ADD TAC,TAC1            ;LAST ADR=2ND ADR+SIZE
2920:         TLZ TAC,-1              ;CLEAR LEFT HALF
2921:         PUSHJ PDP,IADRCK        ;LAST ADDRESS IN BOUNDS?
2922:         JRST TPOPJ              ;NO. ERROR RETURN
2923:         HRLI TAC,PROG           ; SET LAST ADR. FOR RELOCATION
2924:         POP PDP,TAC1            ;RESTORE FIRST ADR.
2925:         NOSHUFF                 ;NO SHUFFLING
2926:         MOVEI TAC1,@TAC1        ; GET ABS. ADDR OF 2ND WD. OF BUFFER
2927:         HRL TAC1,TAC1
2928:         AOBJN TAC1,.+1          ;THIRD WORD IN BUFFER
2929:         SETZM (TAC1)            ;CLEAR THIRD WORD
2930:         AOS TAC1                ;SET DEST. ADR. TO 4TH WORD
2931:         BLT TAC1,@TAC           ;CLEAR BUFFER
2932:         SHUFFLE                 ;SHUFFLING
2933:         JRST CPOPJ1             ;SUCESSFUL RETURN
    COMCSS page# 0078 next  prev
2935: ;ROUTINE TO COMPUTE 12 BIT FOLDED CHECKSUM
2936: 
2937: ;CALL:  PUSHJ PDP,CKS12
2938: ;       EXIT            ALWAYS RETURNS HERE
2939: ;CALCULATES FOLDED 12 BIT CHECKSUMS OF THE DATA WORDS IN THE
2940: ;BUFFER WHOSE ADDRESS IS IN AC TAC1.  TWO ALGORITHMS ARE USED.
2941: ;ON RETURN, THE LEFT HALF OF AC TAC CONTAINS A CHECKSUM OBTAINED
2942: ;BY ACCUMULATING, IN ONE'S COMPLEMENT, THE DATA WORDS AND FOLDING IT.
2943: ;THE LEFT HALF OF AC DAT CONTAINS A CHECKSUM OBTAINED BY ACCUMULATING,
2944: ;IN TWO'S COMPLEMENT, THE DATA WORDS AND FOLDING IT.  AC TAC1
2945: ;CONTAINS A 1.
2946: 
2947: 
2948: CKS12: ADD TAC1,PROG           ;TAC1:=-WORD COUNT,ADDRESS OF FIRST DATA WORD
2949:         AOS TAC1
2950:         HRRZ TAC,0(TAC1)
2951:         MOVNS TAC
2952:         AOS TAC1
2953:         HRL TAC1,TAC
2954:         SETZM TAC               ;INITIALIZE TWO'S COMPLEMENT SUM
2955: CKS12A: ADD TAC,0(TAC1)         ;TWO'S COMPLEMENT ADD
2956:         AOBJN TAC1,CKS12A       ;DONE?
2957:         LSHC TAC,-30
2958:         LSH TAC1,-14
2959:         ADD TAC,TAC1
2960:         LSHC TAC,-14
2961:         LSH TAC1,-30
2962:         ADD TAC,TAC1
2963:         TRZE TAC,770000
2964:         AOS TAC
2965:         HRLZS TAC
2966:         MOVEI TAC1,1            ;TAC1:=1
2967:         POPJ PDP,
    COMCSS page# 0079 next  prev
2969: ;ROUTINE TO CLEAR RESIDUE OF WORD POINTED TO BY A BYTE POINTER
2970: 
2971: ;CALL:  PUSHJ PDP,CLRBYT
2972: ;       EXIT            ALWAYS RETURNS HERE
2973: ;CALLED WITH A BYTE POINTER IN AC TAC, IT CLEARS THE REST OF THE
2974: ;WORD POINTED TO BY THE BYTE POINTER.
2975: 
2976: 
2977: CLRBYT:
2978:         LDB TAC1,[POINT 6,TAC,5]        ; SET UP POINTER
2979:         DPB TAC1,[POINT 12,TAC,11]      ;TAC 0-5:=0,TAC 6-12:=P
2980:         SETZM TAC1
2981:         DPB TAC1,TAC                    ;CLEAR BITS 36-P THROUGH 35
2982:         POPJ PDP,                       ;RETURN
    COMCSS page# 0080 next  prev
2984: ;IOALL, IOALLR, IORELS,IOWAIT
2985: 
2986: IOWAIT:        SKIPA TAC,[WAIT1]       ;WAIT FOR ALL DEVICES TO BE INACTIVE
2987: IORELS:        MOVEI TAC,RELEA3        ;RELEASE ALL IO DEVICES. FALL INTO IOALL
2988: 
2989: ;ROUTINE TO DO IO FOR ALL DEVICES ASSIGNED TO JOB
2990: ;CALL   MOVEI TAC,ADR. OF IO SUB.
2991: ;       PUSHJ PDP,IOALL
2992: 
2993: IOALL: PUSH PDP,TAC                    ; SAVE SUBROUTINE CALL
2994:         SETZB UCHN,UUO                  ;START WITH USER CHANNEL 0
2995:         SKIPL DEVDAT,USRHCU(PID)        ; IS THIS NEGATIVE?
2996:         JRST IOALL1
2997:         SETZM USRHCU(PID)               ;SAVE-GET HAS BEEN HERE, RELEASE DEVICE ANYWAY!!!
2998:         JRST IOALL2
2999: IOALL1: CAMLE UCHN,USRHCU(PID)          ;IS IT GREATER THAN HIGHEST CHAN. USED?
3000:         JRST IOALLP                     ;YES, POP PDP,TAC; POPJ PDP,
3001:         SKIPN DEVDAT,USRJDA(UCHN)       ;GET NEXT DDB ADR., IS IT IN USE?
3002:         AOJA UCHN,IOALL1                ;NO, KEEP GOING
3003: IOALL2: MOVE IOS,DEVIOS(DEVDAT)
3004:         DPB UCHN,PUUOAC
3005:         MOVE DSER,DEVSER(DEVDAT)        ;SETUP ADR. OF DEV. DISP. TABLE
3006:         LDB J,PJOBN                     ;DOES THIS DDB BELONG
3007:         CAMN J,JOB(PID)                 ;TO THIS JOB?
3008:         PUSHJ PDP,@(PDP)                ;YES, CALL THE SUB.
3009:         MOVE J,JOB(PID)                 ;KEEP THIS HONEST
3010:         AOJA UCHN,IOALL1                ;INCREMENT USER CHAN. NO.
3011: 
3012: IOALLP: SKIPL UCHN,JBTIOP(J)            ;GET IO PDL POINTER
3013:         JRST TPOPJ                      ;NONE THERE. RETURN
3014:         PUSH P,[-1]
3015: IOALP1: SKIPN DDB,(UCHN)                ;SKIP FLUSHED CHANNELS
3016:         JRST IOALP2
3017:         EXCH DDB,USRJDA
3018:         MOVEM DDB,(UCHN)                ;EVERYONE MUST LIVE SOMEWHERE
3019:         MOVE DDB,USRJDA
3020:         PUSH P,UCHN
3021:         SETZ UCHN,
3022:         MOVE IOS,DEVIOS(DDB)
3023:         DPB UCHN,PUUOAC
3024:         MOVE DSER,DEVSER(DDB)           ;SETUP ADR. OF DEV. DISP. TABLE
3025:         LDB J,PJOBN                     ;DOES THIS DDB BELONG
3026:         CAMN J,JOB(PID)                 ;TO THIS JOB?
3027:         PUSHJ P,@-2(P)                  ;YES, CALL THE SUB.
3028:         MOVE J,JOB(PID)                 ;KEEP THIS HONEST
3029:         POP P,UCHN
3030:         MOVE DDB,(UCHN)
3031:         EXCH DDB,USRJDA
3032:         MOVEM DDB,(UCHN)
3033:         JUMPE DDB,IOALP2
3034:         SETZM (P)                       ;FLAG TO NOT RETURN JBTIOP
3035: IOALP2: ADD UCHN,[1,,1]
3036:         AOBJN UCHN,IOALP1
3037:         POP P,TAC
3038:         JUMPE TAC,TPOPJ
3039:         PUSH P,AC1
3040:         HRRZ AC1,JBTIOP(J)              ;FLUSH IO STACK
3041:         SETZM JBTIOP(J)
3042:         PUSHJ P,FSGIVE
3043:         POP P,AC1
3044:         JRST    TPOPJ
3045: 
3046: 
3047: ;HERE TO CHASE THROUGH THE DDB LIST AND CALL RELEA5 FOR ANY DDB OF OURS
3048: ;CALLED FROM IOKILL
3049: ;THIS IS A KLUDGE TO RECTIFY THE PROBLEM OF DDBS GETTING LOST FROM JOBJDA
3050: 
3051: IOALLR: PUSH    P,USRJDA
3052:         MOVEI   DDB,DEVLST-DEVSER
3053: IOALR1: HLRZ    DDB,DEVSER(DDB)
3054:         JUMPE   DDB,IOALR3
3055: IOALR2: LDB     J,PJOBN
3056:         CAME    J,JOB(PID)
3057:         JRST    IOALR1
3058:         MOVE    UCHN,DEVMOD(DDB)
3059:         TRNN    UCHN,ASSPRG             ;ASSIGNED BY PROGRAM?
3060:         JRST    IOALR1                  ;NO
3061:         MOVEM   DDB,USRJDA
3062:         MOVEI   UCHN,0
3063:         DPB     UCHN,PUUOAC
3064:         MOVE    IOS,DEVIOS(DDB)
3065:         MOVE    DSER,DEVSER(DDB)        ;SETUP ADR. OF DEV. DISP. TABLE
3066:         PUSH    P,DSER                  ;SAVE DSER
3067:         PUSHJ   P,RELEA5                ;RELEASE THIS DDB
3068:         POP     P,DDB
3069:         HLRZ    DDB,DDB                 ;ADDRESS OF NEXT DDB
3070:         JUMPN   DDB,IOALR2              ;CONTINUE THROUGH THE DDB CHAIN.
3071: IOALR3: POP     P,USRJDA
3072:         MOVE    J,JOB(PID)              ;KEEP THIS HONEST
3073:         POPJ    P,
    COMCSS page# 0081 next  prev
3075: ;IOKILL, CLRUSR
3076: 
3077: ;KILL ALL DEVICES(RELEASE WITHOUT WAITING FOR DEVICE INACTIVE)
3078: 
3079: IOKILL:
3080:         MOVEI   TAC,RELEA5
3081:         PUSHJ   P,IOALL         ;RELEASE ALL DEVICES WITHOUT WAITING
3082:         PUSHJ   P,IOALLR        ;CHASE THRU DDB LIST AND RELEASE ANY OTHERS
3083: 
3084: ;ROUTINE TO CLEAR PROTECTED JOB DATA AREA IN MONITOR
3085: ;AND RECLAIM FREE AREA ABOVE USER PROGRAM FOR IO BUFFERS
3086: 
3087:         HLRZ    TAC,JOBSA(JDAT) ;RESET FIRST FREE LOC. FOR THIS JOB
3088:         MOVEM   TAC,JOBFF(JDAT)
3089: CLRUSR:
3090:         SETZM   JOBENB(JDAT)    ;INITIALIZE USER FOR NO TRAPS ENABLED
3091:         MOVEI   TAC,USRLO1(PID) ;FIRST LOC+1 TO CLEAR
3092:         HRLI    TAC,USRLO(PID)  ;FIRST LOC.
3093:         SETZM   USRLO(PID)
3094:         BLT     TAC,USRHI(PID)
3095:         SETZM   USRHCU(PID)     ;CLEAR HIGHEST USER IO CHAN. IN USE
3096:         POPJ    P,
3097: 
    COMCSS page# 0082 next  prev
3099: ;ROUTINE TO FLAG DEVICE ACTIVE  - ORACT, SETACT, CLRACT, STOIOS
3100: ;CALL   MOVE IOS,IO STATUS BITS
3101: ;       MOVE DEVDAT,ADDRESS OF DEVICE DATA BLOCK
3102: ;       PUSHJ PDP,SETACT
3103: ;CALLED BY ALL IO SERVICE ROUTINES AT UUO AND INTERRUPT LEVELS
3104: 
3105: 
3106: 
3107: ORACT: SKIPE SPWUUF(PID)
3108:         CONSZ PI,77000
3109:         CAIA
3110:         JRST SPWERR
3111:         TRO IOS,IOACT
3112:         IORB IOS,DEVIOS(DDB)
3113:         JRST ORACT1
3114: SETACT:
3115:         SKIPE SPWUUF(PID)
3116:         CONSZ PI,77000
3117:         CAIA
3118:         JRST SPWERR
3119:         TROE IOS,IOACT
3120:         JRST STOIOS
3121:         TLZA    IOS,IOW
3122: CLRACT:
3123:         TRZ IOS,IOACT
3124: STOIOS:
3125:         MOVEM IOS,DEVIOS(DDB)
3126: ORACT1: LDB TAC,PDVTIM          ;GET NO. OF SECONDS
3127:         DPB TAC,PDVCNT          ;TO WAIT BEFORE
3128:         POPJ P,         ;DEVICE IS CONSIDERED HUNG
    COMCSS page# 0083 next  prev
3130: ; THIS ROUTINE UPDATES EACH DEVICE'S HUNG COUNT AND DISPATCHES
3131: ; IF THE COUNT IS EXHAUSTED
3132: 
3133: DEVCHK:
3134:         MOVEI TAC,JIFSEC        ; RESET HUNG DEVICE CHECK TIME
3135:         MOVEM TAC,HNGTIM        ;TO CHECK ONCE A SECOND
3136: ;       HLRZ DEVDAT,DEVLST
3137:         SOSN DSKHNG             ;SEE IF DISK IS HUNG THIS WAY!
3138:         PUSHJ P,DSKDSP+DHNG     ;CALL DISK HUNG ROUTINE
3139:         MOVEI DDB,PTRDDB        ;SKIP DSK AND UDP
3140: DEVCK0: MOVE IOS,DEVIOS(DEVDAT) ;IS DEVICE ACTIVE?
3141:         TRNN IOS,IOACT
3142:         JRST DEVCK2             ;NO
3143: DEVCK3: LDB TAC,PDVCNT          ; YES, DECREMENT HUNG COUNT
3144:         SOJL TAC,DEVCK1         ;0 MEANS IGNORE DEVICE
3145:         DPB TAC,PDVCNT          ; NOW REPLACE IT IN THE DDB
3146:         JUMPN TAC,DEVCK1        ;HAS COUNT GONE TO 0?
3147:         MOVE DSER,DEVSER(DEVDAT);YES, GET DISPATCH TABLE ENTRY
3148:         PUSH PDP,DEVDAT
3149:         PUSHJ PDP,DHNG(DSER)    ;DISPATCH TO SERVICE ROUTINES TO 
3150:                                 ;UNHANG DEVICE
3151:         PUSHJ PDP,DEVHNG        ;PRINT ERROR MESSAGE AND STOP JOB
3152:         POP PDP,DEVDAT          ;DO NOT PRINT MESS. AND STOP JOB RETURN
3153: DEVCK1: HLRZ DEVDAT,DEVSER(DEVDAT)
3154:         CAIE DEVDAT,TTYLST      ;DON'T DO TTY'S
3155:         JUMPN DEVDAT,DEVCK0
3156:         POPJ PDP,
3157: 
3158: DEVCK2: MOVE DAT,DEVCMR(DEVDAT) ; PULL IN EXTRA DEVCHR BITS
3159:         TLNE DAT,DEVIBF         ; DOES THIS DEVICE HAVE AN INTERNAL BUFFER?
3160:         TLNN IOS,DEVSBB         ; IF IT DOES, IS IT BUSY?
3161:         JRST DEVCK1             ; NOT BUSY, IGNORE DEVICE
3162:         JRST DEVCK3             ; BUSY, INCREMENT HUNG COUNT
    COMCSS page# 0084 next  prev
3164: ; OTHER USEFUL ROUTINES FOR SETING UP USER BUFFER POINTERS
3165: ; CHECK RING USE BIT AND SEE IF USER HAS ANOTHER BUFFER TO FILL
3166: ; SET UP DEVDAT AND PROG
3167: ; DOES SCRATCH WORK IN TAC
3168: ; SKIPS IF HE HAS BUFFERS HE CAN BE FILLING
3169: 
3170: DEVCR: HLR TAC,DEVBUF(DEVDAT)  ; PICK UP RELATIVE ADDRESS OF HIS BUFFER HEADER
3171:         HRLI TAC,PROG           ; SET TO INDEX BY HIS RELOCATION CONSTANT
3172:         HRR TAC,@TAC            ; WE NOW HAVE THE ABSOLUTE ADDRESS OF THE FIRST BUFFER
3173:         SKIPL @TAC              ; CHECK THE RING USE BIT, AGAIN INDEXED BY PROG
3174:         AOS (PDP)               ; BUFFER IS FREE, LET HIM FILL IT
3175:         POPJ PDP,
    COMCSS page# 0085 next  prev
3177: ; SET UP WORD COUNT IN AC2
3178: ; SET UP 7-BIT BYTE POINTER TO ACTUAL DATA IN AC3
3179: ; DEVDAT AND PROG MUST BE SET UP
3180: ; ROUTINE SKIPS ON SUCCESS, DOESN'T SKIP IF BUFFER IS EMPTY
3181: 
3182: DEVSTU:
3183:         SKIPL @DEVOAD(DEVDAT)   ; FIRST, SEE IF THIS BUFFER HAS ALREADY BEEN EMPTIED
3184:         POPJ PDP,               ; YES IT HAS, EXIT NOW
3185:         MOVEI AC3,@DEVOAD(DEVDAT)
3186:         HRRZ AC2,1(AC3)         ; WORD COUNT IS LOCATED 1 LOC AFTER HEADER ADDRESS
3187:         ADD AC3,[POINT 7,2]     ; MAKE ABSOLUTE ADDRESS INTO A BYTE POINTER TO THE WORD AFTER THE WORD COUNT
3188:         AOS (PDP)               ; SKIP UPON SUCCESS
3189:         POPJ PDP,
    COMCSS page# 0086 next  prev
3191: ;ROUTINE TO SETUP PROG AND ITEM FOR INTERRUPT SERVICE ROUTINE
3192: 
3193: ;CALL   PUSHJ PDP,IOSET
3194: ;       EXIT    ALWAYS RETURNS HERE
3195: ;THIS PROGRAM IS CALLED FROM AN INTERRUPT SERVICE ROUTINE.
3196: ;IT PUTS THE ADDRESS OF THE DATA AREA OF THE JOB (C(JBTADR18-35))
3197: ;CONNECTED TO THE DEVICE SPECIFIED BY AC DEVDAT IN AC PROG AND
3198: ;PUTS THE ITEM POINTER (C(DEVCTR)) IN AC ITEM.
3199: 
3200:         
3201: 
3202: IOSET: LDB PROG,PJOBN
3203:         MOVE ITEM,DEVCTR(DEVDAT)        ;ITEM:=ITEM POINTER=C(DEVCTR)
3204:         MOVE PROG,JBTADR(PROG)          ;PROG:=C(JBTADR 18-35)
3205:         POPJ PDP,                       ;RETURN
    COMCSS page# 0087 next  prev
3207: ;CALLING SEQUENCE
3208: ;       PUSHJ PDP,IOSETC
3209: ;       EXIT            ALWAYS RETURNS HERE
3210: 
3211: ;SETS JBFPTR18-35:=C(TAC1 18-35)
3212: ;       JBFCTR:=C(ITEM)*[WORD LENGTH/BYTE SIZE]
3213: ;WHERE  WORD LENGTH:=36 DECIMAL
3214: ;       BYTE SIZE:=C(JBFPTR6-11)
3215: ;       [X]:= INTEGER PART OF X
3216: 
3217: 
3218: 
3219: 
3220: IOSETC:
3221:         ADDI    JBUF,1                  ;JBFPTR12-18 SET TO 0
3222:         MOVSI   TAC,7777                ;JBFPTR18-35:=C(TAC1 18-35)+1
3223:         XCTR    XRW,[ANDM TAC,(JBUF)]
3224:         XCTR    XRW,[HRRM TAC1,(JBUF)]
3225:         XCTR    XRW,[AOS (JBUF)]
3226: ;NEXT 3 INST'S ADDED BY RPH TO AVOID INVALID WORD COUNTS 10-11-72
3227:         XCTR    XLB,[LDB TAC1,[POINT 17,(TAC1),17]]     ;GET BUFFER SIZE
3228:         CAILE   ITEM,-1(TAC1)                   ;MORE DATA INDICATED THAN CAN BE IN BUFFER?
3229:         MOVEI   ITEM,-1(TAC1)                   ; YES, SET TO MAX
3230:         XCTR    XLB,[LDB TAC1,[POINT 6,(JBUF),11]]      ;TAC1:=BYTE SIZE
3231:         PUSHJ   P,ITMCT1                        ;JBFCTR:=C(ITEM)*[36/BYTE SIZE]
3232:         ADDI    JBUF,1
3233:         XCTR    XW,[MOVEM ITEM,(JBUF)]
3234:         POPJ    P,                              ;EXIT
    COMCSS page# 0088 next  prev
3236: ;ROUTINE TO RETURN NO. OF ITEMS IN BUFFER
3237: 
3238: ;CALL:  PUSHJ PDP,ITMSET
3239: ;       EXIT            ALWAYS RETURNS HERE
3240: ;SETS AC ITEM:=(BUFFER SIZE-1)*[WORD LENGTH/BYTE SIZE]
3241: ;WHERE BUFFER SIZE:=BITS 1-17 OF THE BUFFER HEADER WORD POINTED TO
3242: ;               BY C(DEVADR)
3243: ;       WORD LENGTH:=36 DECIMAL
3244: ;       BYTE SIZE:=INTEGER PART OF X.
3245: 
3246: ;CALLING SEQUENCE
3247: ;       PUSHJ PDP,ITMCNT
3248: ;       EXIT            ALWAYS RETURNS HERE
3249: ;SETS AC ITEM:=C(ITEM)*[WORD LENGHT/BYTE SIZE]
3250: 
3251: ITMSET:
3252:         LDB ITEM,[POINT 17,@DEVADR(DEVDAT),17]
3253:         SUBI ITEM,1
3254:         LDB TAC1,[POINT 6,DEVPTR(DEVDAT),11]
3255: ITMCT1:
3256:         MOVEI TAC,44            ; GET C(ITEM):=C(ITEM)*[WORD LENGTH/C(TAC1)]
3257:         IDIV TAC,TAC1
3258:         IMUL ITEM,TAC
3259:         POPJ PDP,
    COMCSS page# 0089 next  prev
3261: ;ROUTINE TO SET DEVICE STATUS WORD FROM UUO
3262: ;AND SETUP IOS
3263: 
3264: 
3265: SETIOS:
3266:         PUSHJ PDP,WAIT1
3267:         PUSHJ   P,SETMOD
3268:         JRST    ILLMOD
3269:         POPJ    P,
3270: 
3271: SETMOD:
3272:         LDB TAC1,[POINT 4,UUO,35]       ;GET DEVICE DATA MODE
3273: SETIO2: MOVEI TAC,1             ;AND CHECK FOR LEGALITY
3274:         LSH TAC,(TAC1)
3275:         TDNN TAC,DEVMOD(DEVDAT)
3276:         JRST SETIO1
3277:         TRZ UUO,IOACT           ;LET USER SET ALL BITS EXCEPT IOACT
3278:         HRRM UUO,DEVIOS(DEVDAT)
3279:         JRST    CPOPJ1
3280: 
3281: SETIO1: CAIE TAC1,2             ;MODE 2?
3282:         POPJ    P,              ;NO. ILL MODE
3283:         MOVEI TAC1,D            ;YES. TRY MODE 17 INSTEND.
3284:         ADDI UUO,D-2
3285:         JRST SETIO2
    COMCSS page# 0090 next  prev
3287: ;SETUP BYTE POINTER AND ITEM COUNT
3288: ;CALLED BY STODAT ONLY (AT INTERRUPT LEVEL)
3289: ;CALL   PUSHJ PDP,NEWBUF
3290: ;       ADDRESS CHECK WHEN SETTING UP BUFFER
3291: ;       OK RETURN
3292: 
3293: 
3294: 
3295: 
3296: 
3297: NEWBUF: HRRZ TAC,DEVADR(DEVDAT) ;TAC:=INPUT BUFFER HEADER ADDRESS
3298:         PUSHJ PDP,BUFCLR        ;CLEAR INPUT BUFFER.
3299:         POPJ PDP,               ;ADDRESS CHECK
3300:         HRR TAC,DEVADR(DEVDAT)
3301:         HRLZI TAC,7737
3302:         AND TAC,DEVPTR(DEVDAT)  ;DEVPTR 0-5:=0, DEVPTR 12:=0
3303:         HRR TAC,DEVADR(DEVDAT)  ;DEVPTR 18-35:=C(DEVADR 18-35) + 1
3304:         AOS TAC
3305:         MOVEM TAC,DEVPTR(DEVDAT)
3306:         PUSHJ PDP,ITMSET        ;ITEM:=(BUFFER SIZE-1)*[36/BYTE SIZE]
3307:         MOVEM ITEM,DEVCTR(DEVDAT)       ;DEVCTR:=ITEM COUNT
3308:         JRST CPOPJ1             ;RETURN
    COMCSS page# 0091 next  prev
3310: ;ROUTINE TO SETUP BYTE POINTER ACCORDING TO DATA MODE
3311: 
3312: ;CALL:  PUSHJ PDP,SETBYT
3313: ;       EXIT            ALWAYS RETURNS HERE
3314: ;SETS   TAC 0-5:=0
3315: ;       TAC 6-11:=S
3316: ;       TAC 12-13:=0
3317: ;       TAC 14-17:=PROG
3318: ;WHERE S=36 IF DATA MODE (IOS 32-25) IS BINARY (B)
3319: ;       IMAGE (I), IMAGE BINARY (IB), OR DUMP (SD,D,DR)
3320: ;      S=7  IF DATA MODE IS     ASCII PACKED (A)
3321: ;                       ASCII LINE (AL)
3322: ;                       ASCII SEQUENCED (AS)
3323: ;                       ASCII SEQUENCED LINE (ASL)
3324: ;               OR      ALTERNATE MODE BREAK (AM)
3325: 
3326: 
3327: SETBYT:
3328:         TRNN IOS,14             ; IS MODE LESS THAN 10?
3329:         HRLI TAC,700+PROG       ;YES,ASCII OR ASCII LINE
3330:         TRNE IOS,14             ;10 OR GREATER?
3331:         HRLI TAC,4400+PROG      ;YES, IMAGE,IMAGE BIN. OR BIN.
3332:         POPJ PDP,
    COMCSS page# 0092 next  prev
3334: ; ROUTINE TO STORE DATA IN IOBUFFER FOR INPUT DEVICES THAT
3335: ; OPERATE CHARACTER AT A TIME.
3336: 
3337: ; CALLING SEQUENCE . . .
3338: ;       PUSHJ PDP,STODAT
3339: ;       EXIT1        CHECKSUM ERROR
3340: ;       EXIT2        BLOCK FULL OR BLOCK BOMPLETE
3341: ;       EXIT3        DATA STORED CORRECTLY
3342: ; CALLED FROM AN INPUT SERVICE ROUTINE WITH A DATA ITEM IN AC DAT.
3343: ; STORES THE DATA ITEM IN THE BUFFER, CHECKING TO SEE IF IT WERE
3344: ; THE FIRST ITEM ON THE BUFFER AND SETTING UP THE POINTER AND
3345: ; WORD COUNT APPROPRIATELY CHECKING THE MODE TO SEE IF ANY SPECIAL
3346: ; PROCESSING NEED BE DONE. FOR EXAMPLE, THE TERMINATION
3347: ; OF A BUFFER ON CERTAIN CHARACTERS IN OTHER MODES, OR IF THE BUFFER
3348: ; IS FULL. THERE ARE THREE RETURNS FROM THIS ROUTINE: THE FIRST
3349: ;RETURN OCCURS ON AN ERROR CONDITION, THE SECOND RETURN OCCURS
3350: ;ON A BLOCK FULL CONDITION OR BLOCK COMPLETE CONDITION, THE THIRD
3351: ;RETURN OCCURS ON THE DATA STORED CORRECTLY CONDITION.  THIS
3352: ;ROUTINE ALSO DOES SOME CHECKING ON INPUT OF BINARY RECORD,
3353: ;PAPER TAPE OR CARDS.
3354: ;CALLING SEQUENCE
3355: ;       PUSHJ PDP,STOSQD
3356: ;       XXXX            ALWAYS SKIPS 
3357: ;       EXIT            ALWAYS RETURNS HERE
3358: ;STORES THE WORD COUNT:=C(DEVPTR 18-35) -C(DEVIAD 18-35) - 1
3359: ;IN THE BUFFER.
    COMCSS page# 0093 next  prev
3361: STODAT:
3362:         TLNN IOS,IOFST          ; IS THIS FIRST ITEM OF BUFFER?
3363:         JRST STO0               ;NO
3364:         PUSHJ PDP,NEWBUF        ;SET UP A NEW BUFFER. ITEM:=(BUFFER 
3365:                                 ;SIZE - 1)*[36/BYTE SIZE]
3366:         POPJ PDP,
3367: STO0:   LDB TAC1,PIOMOD         ;DATA MODE
3368:         CAIN TAC1,B             ;MODE=BINARY?
3369:         JRST STOBIN
3370:         TLZ IOS,IOFST
3371: STO1:   IDPB DAT,DEVPTR(DEVDAT) ;STORE DATA IN BUFFER.
3372:         CAIE TAC1,A             ;MODE=ASCII, IMAGE, OR BINARY?
3373:         CAIN TAC1,I
3374:         JRST STOAIB
3375:         CAIE TAC1,IB            ;IMAGE BINARY?
3376:         CAIN TAC1,B             ;CHECKSUM BINARY?
3377:         JRST STOAIB             ;YES
3378:         ANDI    DAT,177         ;NO, MUST BE ASCII LINE MODE.
3379:         CAIG     DAT,14         ;LINE FEED,FORM FEED, OR VERTICAL TAB?
3380:         CAIGE   DAT,12
3381:         JRST .+2                ;NO
3382:         JRST STOSQF             ;YES
3383:         SOJGE ITEM,CPOPJ2       ;ITEM:=C(ITEM)-1. IS C(ITEM)>OR=0?
3384: STOE1:  TRO IOS,IOBKTL  ;IOBKTL:=1
3385:         POPJ PDP,
3386: STOAIB: SOJG ITEM,CPOPJ2;       ITEM:=C(ITEM)-1. IS C(ITEM)>0?
3387:         CAIN TAC1,A             ;MODE=ASCII?
3388:         JRST STOSQF             ;YES
3389:         CAIN TAC1,B             ;MODE=BINARY?
3390:         JRST STOBND             ;YES, COMPUTE CHECKSUM AND CHECK.
3391:         PUSHJ PDP,ITMSET        ;ITEM:=(BUFFER SIZE-1)*[36/BYTE SIZE]
3392:                                 ; - C(DEVCTR)
3393:         SUB ITEM,DEVCTR(DEVDAT)
3394:         MOVE TAC1,DEVIAD(DEVDAT);STORE ITEM COUNT
3395:         ADDI ITEM,1             ;IN FIRST WORD OF BUFFER
3396:         AOJA TAC1,STOSQE
    COMCSS page# 0094 next  prev
3398: STOSQD:
3399:         TLZN IOS,IOFST          ; FIRST CALL?
3400:         JRST STOSQF             ;NO
3401:         PUSHJ PDP,NEWBUF        ;YES, CLEAR BUFFER,SET ITEM COUNT
3402:         POPJ PDP,               ;ADDRESS CHECK
3403: STOSQF: MOVE TAC1,DEVIAD(DEVDAT)        ;REL. ADR. OF BUFFER
3404:         AOS TAC1
3405:         HRRZ ITEM,DEVPTR(DEVDAT)        ;ITEM:=C(DEVPTR 18-35) -
3406:                                 ;C(DEVIAD 18-35) -1
3407:         SUBI ITEM,(TAC1)
3408: STOSQE: HRRM ITEM,@TAC1         ;WORD COUNT TO FIRST WORD IN BUFFER
3409:         JRST CPOPJ1             ;EXIT2. BLOCK COMPLETE
3410: 
3411: 
3412: STOBIN: TLZN IOS,IOFST          ;WILL THE NEXT ITEM BE THE FIRST ITEM
3413:         JRST STO1               ;OF A BUFFER?  IOFST:=0
3414:         HRRZ TAC,DAT            ;YES.
3415:         CAMLE TAC,ITEM          ;IS WORD COUNT <OR= (BUFFER SIZE-1)*
3416:         JRST STOE1              ;   [36/BYTE SIZE]?
3417:         MOVE ITEM,TAC           ;ITEM:=WORD COUNT
3418:         MOVEM DAT,@DEVPTR(DEVDAT)       ;STORE WORD COUNT IN BUFFER
3419:         JRST CPOPJ2             ;EXIT3.  DATA STORED CORRECTLY.
3420: 
3421: STOBND: HRRZ TAC1,DEVIAD(DEVDAT)
3422:         PUSHJ PDP,CKS12         ;COMPUTE CHECKSUM
3423:         ADD TAC1, DEVIAD(DEVDAT)
3424:         HLLZ TAC1,@TAC1         ;DATA CHECKSUM=COMPUTED CHECKSUM?
3425:         CAMN TAC,TAC1
3426:         JRST CPOPJ1             ;EXIT2. BLOCK COMPLETE
3427:         TRO IOS,IODTER          ;IODTER:=1
3428:         JRST CPOPJ              ;EXIT1.  CHECKSUM ERROR
3429: 
3430: 
    COMCSS page# 0095 next  prev
3432: SUBTTL  RUNCSS  4 AUG 67 - KSTOP
3433: 
3434: ;RUN CONTROL IS A COLLECTION OF ROUTINES WHICH
3435: ;SET AND CLEAR BITS IN THE JOB STATUS WORDS OF
3436: ;ALL JOBS SO THAT THE SCHEDULER WILL START AND STOP
3437: ;THEM ACCORDINGLY
3438: 
3439: ;COMMON ERROR STOPPING ROUTINES
3440: ;CALLED AT ANY LEVEL(UUO,CLK, OR INTERRUPT)
3441: ;CALL:  MOVE ITEM,JOB CAUSING ERROR OR BEING STOPPED
3442: ;       MOVE DEVDAT,ADRRESS OF THAT JOB TTY DEVICE DATA BLOCK
3443: ;       MOVE DAT,BYTE POINTER TO LAST CHAR. ALREADY MOVED
3444: ;                       ;TO TTY OUTPUT BUFFER
3445: ;       PUSHJ PDP,KSTOP,PHOLD,HOLD,OR ESTOP
3446: ;       NEVER RETURN IF CALLED AT UUO LEVEL
3447: 
3448: ;ROUTINE TO STOP JOB AFTER KJOB COMMAND
3449: ;CALLED AT UUO LEVEL IF JOB HAD CORE,CLK LEVEL IF NOT
3450: 
3451: 
3452: KSTOP: MOVSI   TAC,JNA!JLOG!JACCT      ;CLEAR BITS 
3453:         ANDCAM  TAC,JBTSTS(J)
3454:         SKIPN   JBTADR(J)
3455:         JRST    KSTOP1
3456:         PUSHACS
3457:         PUSHJ   P,DISMES
3458:         ASCIZ   /JBTADR NOT ZERO AT KSTOP.  CALL A DOCTOR DOUBLE QUICK.   /
3459:         PUSHJ   P,DISJOB
3460:         PUSHJ   P,DISCRLF
3461:         PUSHJ   P,DISFLU
3462:         PUSHJ   P,DDTCALL
3463:         POPACS
3464: KSTOP1:
3465: 
3466: 
3467:         MOVNI   TAC,NULQ                ;PUT HIM IN NULL QUEUE
3468:         MOVEM   TAC,JOBQUE(J)           ;SO SWAPPER WILL FORGET ABOUT HIM
3469:         PUSHJ   P,REQUE
3470:         PUSHJ P,FLUSIN                  ;FLUSH FROM SWAP IN LIST
3471: IFN FTLOGIN,<
3472:         SETZM   PRJPRG(J)               ;KEEP TABLE ACCURATE
3473: >
3474:         SETZM   JOBNAM(J)
3475:         SETZM   TTIME(J)                ;CLEAR RUN TIME FOR R. GORIN
3476:         SETZM   JBTBTM(J)               ;CLEAR LOGIN TIME FOR ACCOUNTING
3477:         SETZM   JBTGSL(J)               ;CLEAR GUARANTEED SERVICE WORDS
3478:         SETOM   JBTWKM(J)               ;WAKE ON ALL INTERRUPTS
3479:         JRST    ESTOP2
    COMCSS page# 0096 next  prev
3481: ;ROUTINE TO STOP JOB, SET ERROR BIT AND PRINT MESSAGE - HOLD, PHOLD
3482: ;THEN ADD ↑C<CRLF><CRLF><PERIOD>
3483: ;CALL:  MOVEI TAC,ADR. OF MESSAGE
3484: 
3485: 
3486: PHOLD: PUSHJ   P,CONMES        ;MOVE MESSAGE TO TTY OUTPUT BUFFER
3487:                                 ;FALL INTO HOLD
3488: ;ROUTINE TO STOP JOB, SET ERROR BIT,
3489: ;AND ADD "↑C<CRLF><CRLF><PERIOD>
3490: 
3491: 
3492: 
3493: HOLD:  PUSHJ   P,PRCRCC
3494:         PUSHJ   P,TTYSTC        ;MAKE SURE TTY STAYS IN MONITOR MODE
3495:                                 ;AND START TTY TYPING OUT MESSAGE
3496:                                 ;FALL INTO ESTOP
    COMCSS page# 0097 next  prev
3498: ;ROUTINE TO STOP USER AND FLAG AS ERROR STOP - ESTOP, MSTOP
3499: 
3500: MSTOP:
3501: ESTOP:
3502:         JUMPE   J,CPOPJ
3503:         SKIPE   SPWUUF(PID)             ;SPACEWAR LEVEL?
3504:         CONSZ   PI,77000                ;YES. ABOVE CH 7?
3505:         CAIA                            ;NOT SPACEWAR (OR ABOVE CH 7)
3506:         JRST    SPWERR                  ;ERROR AT SPACEWAR LEVEL
3507:         MOVSI   TAC,JACCT
3508:         ANDCAM  TAC,JBTSTS(J)           ;NO LONGER AN ACCOUNTING PROGRAM
3509:         MOVSI   TAC,JLOG
3510:         TDNE    TAC,JBTSTS(J)           ;IS THIS JOB REALLY LOGGED IN?
3511:         JRST    ESTOP4                  ;YES, PROCEED NORMALLY
3512:         SKIPN   PROG,JBTADR(J)
3513:         JRST    ESTOP4                  ;NOT LOGGED IN AND NO CORE.
3514:         CONSZ   PI,77400                ;NOT LOGGED IN.  ARE WE AT UUO LEVEL
3515:         JRST    ESTP3B                  ;NO, MUST START MONITOR JOB TO KILL JOB
3516:         SKIPN INTACT(PID)
3517:         JRST ESTP3A                     ;AT UUO LEVEL BUT NOT USER INT LEVEL
3518: ESTP3C: PUSHJ P,ESTOP3                  ;SET JLOG, SETUP MONJOB,
3519:         SETOM ESTINT                    ;TELL CH7 WE'RE COMING FROM ESTOP
3520:         JRST WSCHD2                     ;GET INTO CHANNEL 7
3521: 
3522: ESTP3B: CAMN    J,JOB(PID)              ;PI IN PROGRESS.  JLOG OFF
3523:         SKIPN   INTACT(PID)
3524:         JRST    ESTOP3
3525:         JRST    ESTP3C                  ;CURRENT JOB IS AT USER-INT LEVEL
3526: 
3527: ESTP3A: PUSHJ P,JOBKL1          ;AT UUO LEVEL, CAN KILL JOB FROM HERE
3528:         PUSHACS
3529:         PUSHJ P,DISMES
3530:         ASCIZ /RETURNED FROM JOBKL1 AT ESTOP
3531: /
3532:         POPACS
3533:         JRST ESTOP4                     ;SET ERROR BIT
3534: 
3535: ESTOP3: IORM    TAC,JBTSTS(J)   ; FINISH LOGGING IN JOB SO WE WON'T GET HERE AGAIN
3536:         MOVE    TAC,['-DIE!-']
3537:         MOVEM   TAC,JOBNAM(J)   ; (EVEN IF WE FAIL TO KILL THIS, WE GET NEW PHANTOM)
3538:         PUSHJ   P,INTKIL        ; MAKE SURE THE LOSER CAN'T GET ANY MORE ERRORS - RPH
3539:         JSP     TAC1,MONJOB     ; SET MONITOR JOB TO RUN AND KILL JOB
3540:         JRST    JOBKL           ; HERE AT UUO LEVEL
3541: 
3542: ;GET HERE FROM KSTOP
3543: ESTOP2:
3544:         JUMPE   J,CPOPJ                 ;IS THIS ERROR IN JOB 0?
3545:         SKIPE   SPWUUF(PID)             ;JOB IN SPACEWAR MODE ?
3546:         CONSZ   PI,77000
3547:         CAIA
3548:         JRST    SPWERR                  ;YES. GO TO SPWSER.
3549:         MOVSI   TAC,JACCT               ; ZERO OUT ACCT BIT
3550:         ANDCAM  TAC,JBTSTS(J)           ; SO IF LOGIN BLOWS, WE CAN KILL IT!!
3551: ESTOP4: MOVSI   TAC,JERR                ; SET ERROR BIT
3552:         IORB    TAC,JBTSTS(J)           ;SO JOB CAN NOT CONTINUE(CONT COM.)
3553:         TRNE    TAC,JLOCK
3554:         JRST    [MOVSI TAC,UNLOKC
3555:                 HRR TAC,J
3556:                 CONO PI,PIOFF
3557:                 IDPB TAC,CLKQ           ;USE DPYSLUR CLOCK QUEUE.
3558:                 CONO PI,PION
3559:                 JRST .+1]
3560:         PUSHJ P,INTKILL                 ; CLEAR THE USER INTERRUPT SYSTEM
3561:         CAME J,STUSER                   ;SYSTEM TAPE USER?
3562:         JRST ESTOP6                     ;NO
3563:         MOVSI TAC,'SYS'                 ;FIND SYS DDB
3564:         PUSHJ P,DEVSRC                  ;SYSTEM ERROR IF NOT FOUND
3565:         JRST ESTOP5                     ;BARF!
3566:         PUSHJ P,RELEA9                  ;YES, RELEASE SYSTEM TAPE WITHOUT WAITING
3567:         JRST ESTOP6
3568: 
3569: ESTOP5: PUSHACS
3570:         PUSHJ   P,DISDATE
3571:         PUSHJ   P,DISMES
3572:         ASCIZ   /ππNO DEVICE SYS AT ESTOP!
3573: /
3574:         POPACS
3575: ESTOP6: CAMN J,JOB(PID) ;IF NOT CURRENT JOB
3576:         CONSZ PI,77400  ;OR AT INTERRUPT LEVEL
3577:         JRST STOP1      ;JUST GO TO STOP1 AS ALWAYS
3578:         SKIPE INTACT(PID)
3579:         JRST STOP1      ;ALSO IF FROM USER INT
3580:         PUSHJ P,SETSTP  ;OTHERWISE PUT HIM IN STOPQ, ETC.
3581:         MOVE TAC,UUOPC(J)
3582:         TLNN TAC,USRMOD
3583:         TDZA TAC,TAC    ;GIVE HIM 0 IF PC WAS EXEC
3584:         HRRI TAC,-1(TAC);ELSE BACK IT UP TO LOSING UUO
3585:         MOVEM TAC,UUOPC(J)
3586:         JRST USRX4A     ;NOW CATCH HIM ON HIS WAY "BACK"
    COMCSS page# 0098 next  prev
3588: ;ROUTINE TO STOP ANY JOB FROM BEING SCHEDULED - STOP1, SETSTP
3589: ;CALL:
3590: ;       MOVE    J, JOB NUMBER
3591: ;       PUSHJ   P, STOP1
3592: ;       EXIT    ;RETURN HERE IMMEDIATELY, IF CALLED FROM HIGHER
3593: ;PRIORITY PI CHANNEL THAN CLK(LOWEST), OTHERWISE WHEN JOB IS RUNABLE
3594: ;CALLED FROM COMMAND DECODER WHEN <CONTROL>C TYPED IN BY USER
3595: 
3596: STOP1: PUSHJ   P,SETSTP        ;SET IT TO STOPQ, ETC
3597:         CAME    J,JOB(PID)      ;IS THIS JOB CURRENT USER
3598:         JRST    REQUE           ;NO, SET REQUE JOB FLAG
3599:         SKIPE INTACT(PID)
3600:         SETOM ESTINT            ;TELL CH7 WE'RE COMING FROM ESTOP
3601:         JRST    WSCHD2          ;YES, CALL WSCHED TO WAKE CH7
3602: 
3603: ;THIS ROUTINE DOES ALL THE WORK OF STOPPING THE GUY WITHOUT ACTIVATING CH7
3604: SETSTP: MOVSI   TAC,RUN
3605:         CONO    PI,PIOFF        ;DONE AT INTERUPT LEVEL HIGHER THAN DT LEVEL
3606:         CAME    J,STUSER        ;IS THIS JOB CURRENTLY USING THE SYSTEM TAPE?
3607:         TDNN    TAC,JBTSTS(J)   ;NO, IS RUN BIT OFF IN JOB STATUS WORD
3608:         JRST    STOP1A          ;YES
3609:         ANDCAM  TAC,JBTSTS(J)   ;NO, SO CLEAR IT
3610:         CONO    PI, PION
3611:         MOVM    TAC,JOBQUE(J)   ;GET JOB WAIT QUEUE CODE(IF ANY)
3612:         CAIG    TAC,MAXQ        ;DOES STATE HAVE Q ?
3613:         SOSL    REQTAB(TAC)     ;YES. REDUCE IT.
3614:         JRST    STOP1A          ;NO
3615:         SOSGE   AVALTB(TAC)     ;YES REDUCE  COUNT
3616:         SETZM   AVALTB(TAC)     ;CLEAR AVAL FLAG IF NO ONE WAITING
3617: STOP1A: CONO    PI,PION         ;MAKE SURE PI ON
3618:         MOVNI   TAC,STOPQ       ; REQUE JOB TO STOP QUEUE
3619:         MOVM    TAC1,JOBQUE(J)
3620:         CAIE    TAC1,NULQ       ; UNLESS HE IS IN THE NULL QUEUE
3621:         MOVEM   TAC,JOBQUE(J)
3622:         CAMN    J,LOCKNO        ;WERE WE WAITING TO BE LOCKED IN?
3623:         SETZM   LOCKNO          ;YES. WELL, THERE'S NO ONE THERE ANYMORE.
3624:         POPJ    P,              ;↑C, CONTINUE WILL NOT UNLOCK A JOB!
    COMCSS page# 0099 next  prev
3626: ;DLYCOM     ROUTINE TO REQUE JOB WHICH HAS HAD A COMMAND TYPED
3627: ;WHICH NEEDS CORE AND THE CORE IMAGE IS ON THE DISK.
3628: ;OR IS IN CORE AND HAS ACTIVE DEVICES.
3629: ;CALLED FROM COMMAND DECODER
3630: ;CALL:  MOVE ITEM,JOB NO.
3631: ;       PUSHJ PDP,DLYCOM
3632: 
3633: 
3634: DLYCOM:MOVSI TAC,CMWB                  ; SET COMMAND WAIT BIT
3635:         IORB TAC,JBTSTS(J)              ;IN JOB STATUS WORD
3636:         TLNN TAC,SWP                    ;DO WE NEED HIM IN??
3637:         POPJ P,                         ;IN ALREADY
3638:         MOVSI TAC,COMSNB
3639:         JRST SETSIN
    COMCSS page# 0100 next  prev
3641: ;ROUTINE TO PUT JOB IN NO CORE QUEUE
3642: 
3643: NOCORQ:PUSHJ P,FLUSIN                  ; FLUSH FROM SWAP IN LIST
3644:         MOVEI   TAC,NULQ                ; NO JOB NUMBER OR NO CORE QUEUE
3645:         MOVNM   TAC,JOBQUE(J)
3646:         JRST    REQUE
    COMCSS page# 0101 next  prev
3648: ;ROUTINE TO SETUP MONITOR JOB TO RUN LATER AT UUO LEVEL - MONJOB
3649: ;CALLED BY COMMANDS WHICH MAY OR MAY NOT NEED TO
3650: ;RUN MONITOR JOB DEPENDING ON WHETHER JOB HAS CORE(KJOB,IJOB)
3651: ;TTY WILL REMAIN IN MONITOR MODE
3652: ;JOB MUST HAVE CORE ASSIGNED
3653: ;CALL:  MOVE ITEM, JOB NUMBER
3654: ;       MOVEI TAC1,ADDR. OF MONITOR JOB TO BE RUN
3655: ;       PUSHJ PDP,MONJOB
3656: ;WHEN SCHEDULED TO RUN, MONITOR JOB MUST SET UP ITS OWN ACS
3657: 
3658: 
3659: MONJOB:
3660:         PUSHJ   P,MSTART        ; START WITH PC IN MONITOR
3661:         JRST    SETRUN          ;MCF(JBS);SET TTY TO START JOB WHEN COMMAND RESPONSE
3662:                                 ;IS FINISHED AND KEEP TTY IN MONITOR MODE
    COMCSS page# 0102 next  prev
3664: ;MONSTR ROUTINE TO SETUP ACS FOR MONITOR JOB STARTING AT UUO LEVEL
3665: ;SETS UP J, WITH JOB NO.; PROG WITH RELOCATION, AND P
3666: ;WITH PUSH DOWN LIST ADR. IN JOB DATA AREA
3667: ;USED BY KJOB,CORE 0,SAVE,GET,RUN,R AND FINISH COMMANDS
3668: ;CALL:  MOVEI TAC1,MONITOR JOB STOP ADDRESS
3669: ;       JSP TAC,MONSTR
3670: ;       RETURN WITH ACS P, PROG AND J SETUP
3671: 
3672: 
3673: MONSTR:
3674:         MOVEI   PID,P1PID
3675:         CONSO   APR,MAOFF
3676:         MOVEI   PID,P2PID
3677:         MOVE    J,JOB(PID)      ; GET CURRENT JOB NUMBER
3678:         MOVE    JDAT,JBTDAT(J)  ;ADR. OF JOB DATA AREA
3679: IFN JDMPRG,<
3680:         MOVE    PROG,JBTADR(J)  ;JOB RELOCATION
3681: >
3682:         EXCH    AC1,TAC
3683:         JSP     TAC,GETPDL      ; GET A PUSHDOWN LIST FOR US
3684:         EXCH    AC1,TAC         ; GET OUR RETURN ADDRESS BACK
3685:         PUSH    P,TAC1          ;SAVE STOP ADRRESS
3686:         JRST    (TAC)           ;RETURN AND DO MONITOR JOB
    COMCSS page# 0103 next  prev
3688: ;ROUTINE TO SET JOB STATE TO BE SCHEDULED TO RUN - USTART, MSTART
3689: ;WITH SPECIFIED STARTING ADDRESS INCLUDING PC FLAGS
3690: ;CALLED ONLY WHEN JOB IN CORE AND AFTER JOB HAS BEEN
3691: ;SAFELY STOPPED IN ONE OF 2 STATES:
3692: ;1) PC IN USER MODE
3693: ;2) JOB IN A WAIT FOR SHARABLE DEVICE, OR IO WAIT
3694: ;CALL:  MOVE TAC1,STARTING PC
3695: ;       MOVE ITEM, JOB NUMBER
3696: ;       MOVE JDAT,ADR. OF JOB DATA AREA WHICH MUST BE IN CORE
3697: ;       PUSHJ PDP,USTART(PC TO USER MODE),MSTART(PC TO MONITOR MODE)
3698: ;       RETURN HERE IMMEDIATELY
3699: 
3700: 
3701: USTART:
3702:         MOVE TAC,JOBPC(JDAT)    ; GET OLD PC
3703:         TLNE TAC,USRMOD         ;IS IT IN USER MODE TOO?
3704:         JRST USTRT1             ;YES, DUMP ACS AND PC FLAGS ARE ALREADY HIS
3705:         MOVEI TAC,JOBDAC(JDAT)  ;NO, MOVE USERS(UUO) ACS TO DUMP ACS
3706:         HRL TAC,JDAT            ;SOURCE=REL. 0,DEST.=JOBDAC IN JOB DATA AREA
3707:         BLT TAC,JOBD17(JDAT)    ;MOVE ALL ACS
3708:         MOVE TAC,UUOPC(J)       ; UUO PC HAS LAST KNOWN PC
3709:         TLNN TAC,USRMOD         ;IF NOT USEER MODE
3710:         MOVE TAC,UUOOPC(J)      ;TRY THIS
3711:         TLNN TAC,USRMOD         ;IS IT?
3712:         TLZ TAC,-1              ;NO, CLEAR ALL PC FLAGS
3713:         HRRI TAC,-1(TAC)        ;SUBTRACT 1 FROM RIGHT HALF AND
3714:                                 ;PRESERVE LH PC FLAGS.
3715:                                 ;(RH=0 ON HALT 0 OR FIRST START)
3716: USTRT1: HLL TAC1,TAC            ;PRESERVE USER APR FLAGS
3717:         TLO TAC1,USRMOD         ;MAKE SURE NEW PC IN USER MODE
3718:         TLZ TAC1,37             ;MAKE SURE NO INDIRECT BITS OR INDEX FIELD
3719:         JRST MSTAR1
3720: 
3721: MSTART:MOVE TAC,JOBPC(JDAT)    ; PICK UP USER'S PC
3722:         TLNE TAC,USRMOD         ;IN USER MODE?
3723:         JRST MSTAR1             ;YES, THIS IS CORRECT JOBOPC
3724:         MOVE TAC,UUOPC(J)       ;HERE IS LAST USER PC (MAYBE)
3725:         HRRI TAC,-1(TAC)        ;JUST LIKE USTART
3726: MSTAR1: TLNE TAC,USRMOD         ;IF IT STILL ISN'T USER PC LEAVE HIS OLD ONE
3727:         MOVEM TAC,JOBOPC(JDAT)  ; STORE IT FOR LATER USE
3728:         MOVEM TAC1,JOBPC(JDAT)  ; STORE NEW PC
3729:         CAMN J,JOB(PID)         ;IS THIS CURRENT JOB?
3730:         MOVEM TAC1,USRPC(PID)   ;YES.  STORE IN SYSTEM CORE AS WELL.
3731:         SKIPE INTACT(PID)
3732:         CAME J,SJOB             ;MAKE SURE THAT USRPC IN THE INTERRUPT STACK
3733:         JRST MSTAR2             ;GETS UPDATED
3734:         MOVE TAC,INTSP
3735:         MOVEM TAC1,USRPC-USRJDA-20(TAC)
3736: MSTAR2: PUSHJ P,STXTM2          ;UPDATE INTERACTION RUN TIME FOR THIS JOB
3737:         MOVSI TAC,JERR+WTMASK
3738:         ANDCAM TAC,JBTSTS(ITEM) ;CLEAR ERROR AND WAIT STATUS BITS
3739:         MOVNI TAC,RUNQ          ; REQUE JOB TO RUN QUEUE
3740:         MOVEM TAC,JOBQUE(J)
3741: IFN FTSWAP,<
3742:         SETOM STIME(ITEM)       ; TELL SWAPPER THIS CORE IMAGE HAS BEEN MODIFIED
3743: >
3744:         JRST TTYSET             ;SET TTY STATE TO INITIAL COND.
3745:                                 ;TTYUSR OR TTYURC SHOULD BE CALLED
3746:                                 ;TO INDICATE WHETHER TTY TO USER OR EXEC MODE
3747:                                 ;AND THAT JOB IS TO RUN(RUN BIT =1) WHEN
3748:                                 ;MONITOR COMMAND RESPONSE FINISHES.
3749:                                 ;SET MONITOR MODE
    COMCSS page# 0104 next  prev
3751: ;ROUTINE TO SET JOB STATUS RUN BIT(RUN)
3752: ;CALLED BY SCANNER SERVICE WHEN TTY MONITOR COMMAND
3753: ;RESPONSE FINISHES.  THIS ACTION IS ENABLED BY CALLING
3754: ;TTYUSR, OR TTYURC IN SCNSER
3755: ;CALL:  MOVE ITEM,JOB NUMBER
3756: ;       PUSHJ PDP,SETRUN
3757: 
3758: 
3759: 
3760: SETRUN:
3761:         LDB TAC,[POINT JWSIZ,JBTSTS(J),JWPOS]   ;GET OLD WAIT QUEUE CODE
3762:         JUMPE TAC,SETR1         ;NONE
3763:         AOSE REQTAB(TAC)        ;DEVICE AVAILABLE?
3764:         MOVNM TAC,JOBQUE(J)     ;NO - PUT US BACK INTO WAIT Q
3765: SETR1:  MOVSI TAC,RUN           ;SET RUN BIT IN JOB STATUS WORD
3766:         IORM TAC,JBTSTS(ITEM)
3767: 
3768: 
3769: REQUE: PUSH P,TAC
3770:         MOVEI TAC,QJOB(ITEM)
3771:         CONO PI,PIOFF
3772:         SKIPE (TAC)
3773:         JRST .+3
3774:         EXCH TAC,QJOB
3775:         HRROM TAC,@QJOB
3776:         CONO PI,PION
3777:         JRST TPOPJ
    COMCSS page# 0105 next  prev
3779: ;ROUTINE TO PUT A JOB TO SLEEP AND WAKE UP AGAIN LATER
3780: ;CALLED AFTER CLOCK QUEUE REQUEST PUT IN BY UUO ROUTINE
3781: 
3782: 
3783: 
3784: SETSLP:
3785:         MOVSI TAC,CLKR          ; FLAG THAT A CLOCK REQUEST
3786:                                 ;HAS BEEN PUT IN.
3787:         IORM TAC,JBTSTS(ITEM)   ;SO ONLY ONE PER JOB
3788:         MOVEI AC1,IOWQ          ;SLEEP STATE CODE
3789:         JRST SETSTT             ;SET STATUS AND RESCHEDULE
3790: 
3791: ;HERE AT CLOCK LEVEL WHEN CLOCK REQUEST TIMES OUT FOR SLEEP
3792: ;JOB NO. IN AC TAC
3793: 
3794: 
3795: WAKE:  MOVNI TAC1,RUNQ         ;RUN QUEUE CODE
3796:         MOVE ITEM,TAC           ;JOB NO.
3797:         MOVSI TAC,CLKR          ;CLEAR CLOCK REQUEST BIT FOR THIS JOB
3798:         ANDCAM TAC,JBTSTS(ITEM) ;SO IT CAN PUT ANOTHER ONE IN
3799:         MOVM TAC,JOBQUE(J)      ;GET QUEUE CODE
3800:         CAIE TAC,IOWQ           ;IS JOB STILL SLEEPING?
3801:         POPJ P,                 ;NO
3802:         MOVEM TAC1,JOBQUE(J)    ;YES, STORE RUN QUEUE CODE
3803:                                 ;(CONTROL C, START CAN GET JOB OUT OF SLEEP)
3804:         JRST REQUE
    COMCSS page# 0106 next  prev
3806: ;ROUTINE TO GET DATA CONTROL AND ANOTHER SHARABLE DEVICE
3807: ;JOB NEVER GETS ONE DEVICE AND WAITS FOR SECOND, SINCE TYPING
3808: ;CONTROL C WOULD NEVER FINISH WITH FIRST DEVICE
3809: ;CALL   PUSHJ PDP,GETDCXX
3810: ;       AOSE XXREQ      ;REQUEST COUNT FOR OTHER DEVICE
3811: ;       RETURN WHEN BOTH AVAILABLE
3812: 
3813: 
3814: GETDCDT:↑GETDCMT:
3815:         XCT @(PDP)              ;INCREASE SHARABLE DEVICE REQ. COUNT
3816: GETWT:  PUSHJ PDP,DVWAT1        ;NOT AVAIL., GO WAIT FOR IT
3817:         AOSN DCREQ              ;IS DATA CONTROL AVAILABLE?
3818:         JRST CPOPJ1             ;YES, RETURN BOTH AVAILABLE
3819:         MOVE AC1,@(PDP)         ;DATA CONTROL NOT AVAILABLE
3820:         SUBI AC1,REQTAB
3821:         SOSL REQTAB(AC1)        ;REDUCE REQ. COUNT FOR OTHER
3822:                                 ;SHARABLE DEVICE.
3823:         SETOM AVALTB(AC1)       ;SET AVAILABLE IF OTHER JOBS WAITING
3824:         JFCL DCREQ              ;ARGUMENT FOR DCWAIT
3825:         PUSHJ PDP,DCWAIT        ;WAIT FOR DATA CONTROL FREE
3826:         MOVE AC1,@(PDP)         ;INCREMENT REQ. COUNT
3827:         AOSN @AC1               ;NOW IS SHARABLE DEVICE FREE?
3828:         JRST CPOPJ1             ;YES
3829:         SOSL DCREQ              ;NO, REDUCE DATA CONTROL REQUEST
3830:         SETOM DCAVAL            ;SET AVAIL., SOME OTHER JOB WAITING FOR IT
3831:         JRST GETWT              ;TRY AGAIN
    COMCSS page# 0107 next  prev
3833: ;ROUTINE TO WAIT FOR A SHARABLE DEVICE
3834: ;CALLED AT UUO LEVEL ONLY BY DEVICE SERVICE ROUTINES
3835: ;CALL:  AOSLE XXREQ             ;ADD 1 TO SHARABLE DEVICE REQUEST COUNT
3836: ;                               ;IS DEVICE AVAILABLE?
3837: ;       PUSHJ PDP,XXWAIT        ;NO, PUT JOB IN WAIT QUEUE
3838: ;       RETURN WHEN DEVICE AVAILABLE
3839: 
3840: ;INITIALLY THE REQUEST COUNT IS -N, WHERE N IS THE
3841: ;NUMBER OF JOBS WHICH CAN USE THE SHARABLE DEVICE AT THE SAME TIME
3842: ;A REQUEST COUNT OF 0 MEANS THE MAXIMUM NO. OF JOBS ARE
3843: ;USING THE DEVICE, A POSITIVE NUMBER IS THE
3844: ;NUMBER OF JOBS WAITING IN THE SHARABLE DEVICE WAIT QUEUE
3845: 
3846: 
3847: 
3848: MTWAIT:↑DTWAIT:↑DCWAIT:↑STWAIT:
3849: DVWAIT:
3850:         MOVE AC1,(PDP)          ; GET ADDRESS OF CALLER
3851:         SKIPA AC1,-2(AC1)       ;GET AOSLE XXREQ INSTRUCTION
3852: DVWAT1: MOVE AC1,@-1(PDP)       ;GET ADR. OF CALLER OF THIS ROUTINE
3853:         SUBI AC1,REQTAB         ;COMPUTE WAIT-STATE QUEUE CODE
3854: SETSTT: MOVE AC3,JOB(PID)       ;CURRENT JOB NO.
3855:         HRRZS AC1               ; CLEAN UP JOB QUEUE CODE
3856:         MOVNM AC1,JOBQUE(AC3)   ;STORE IN JOB STATUS WORD
3857:         JRST WSCHED             ;GO SCHEDULE ANOTHER AND RETURN TO CALLER
3858:                                 ;WHEN SHARABLE DEVICE BECOMES AVAILABLE
3859:                                 ;SEE CLOCK AND CLKCSS
3860:                                 ;WORD WAIT QUEUE CODE
    COMCSS page# 0108 next  prev
3862: ;SETIOD - ROUTINE TO SET JOB TO RUN AFTER IT HAS BEEN STOPPED
3863: ;BECAUSE IT HAD TO WAIT FOR IO TO COMPLETE FOR SOME DEVICE
3864: ;EACH SERVICE ROUTINE AT INTERRUPT LEVEL
3865: ;CHECK EACH TIME IT FINISHED A TASK(BUFFERFUL)
3866: ;TO SEE IF THE JOB USING THE DEVICE HAS
3867: ;PREVIOUSLY CAUGHT UP WITH DEVICE AND HAS BEEN STOPPED
3868: ;CALL:  MOVE DEVDAT,ADR. OF DEVICE DATA BLOCK
3869: ;       MOVE IOS,DEVIOS(DEVDAT) ;GET DEVICE IO STATUS WORD FROM DDB
3870: ;       TLZE IOS,IOW    ;IS JOB IN AN IO WAIT FOR THIS DEVICE?
3871: ;       PUSHJ PDP,SETIOD        ;YES, GO FLAG JOB TO START UP AGAIN
3872: ;       RETURN
3873: ; REQUEUES JOB TO A RUN QUEUE
3874: ;THE SCHEDULER THEN SEES THAT THIS JOB HAS ITS
3875: ;IO WAIT SATISFIED AND IS WAITING TO BE RUN AGAIN
3876: 
3877: 
3878: ;!! No longer clobbers ac's !   DWP.
3879: 
3880: STTIOD:PUSH P,[-TQ]    ;HE'S A TTY.  PUT HIM IN SPECIAL HIGH-PRIORITY QUEUE
3881:         CAIA
3882: SETIOD:PUSH P,[-RUNQ]          ; REQUE TO WAIT SATISFIED QUEUE
3883:         EXCH J,(P)
3884:         PUSH P,J
3885:         LDB J,PJOBN             ;Get job no.
3886:         SKIPL JBTSTS(J)         ; IS JOB STILL RUNNING?
3887:         JRST [  POP P,J         ;No.
3888:                 POP P,J
3889:                 POPJ P,]
3890:         POP P,JOBQUE(J)
3891:         PUSHJ   PDP,REQUE       ;ARRANGE TO REQUE THIS JOB.
3892:         POP P,J
3893: NULTST: SKIPE JOB(PID)          ;IS NULL JOB RUNNING?
3894:         POPJ PDP,               ;NO LET OTHER JOB RUN
3895:         CONO PI,PIOFF
3896:         JRST STOP2
    COMCSS page# 0109 next  prev
3898: ;ROUTINE TO CAUSE CLK ROUTINE TO RESCHEDULE - WSCHED
3899: ;CALLED AT ANY LEVEL
3900: ;CALL:  PUSHJ PDP,STOP2 
3901: ;       RETURN IMMEDIATELY EXCEPT IF AT UUO LEVEL
3902: ;       IF AT UUO LEVEL, RETURN WHEN JOB IS RUNABLE AGAIN
3903: 
3904: 
3905: WSCHED: JUMPE PID,WSCHD1
3906:         PUSHACS
3907:         CONSZ APR,MAOFF
3908:         JRST WSCHDA
3909:         PUSHJ P,DISMES
3910:         ASCIZ/ππPDP-6 AT WSCHED
3911: /
3912:         POPACS
3913:         PUSHJ P,DISFLUSH
3914:         JRST AUTOLOAD
3915: WSCHDA: PUSHJ P,DISMES
3916:         ASCIZ/ππPID CLOBBERED AT WSCHED
3917: /
3918:         POPACS
3919: WSCHD1: SKIPE SPWUUF(PID)       ;MAKE SURE WE'RE NOT IN A SPACEWAR JOB
3920:         JRST SPWERR
3921: WSCHD2: AOS NWSCHEDS            ; MARK ANOTHER ONE GONE
3922:         CONO PI,PIOFF           ;AVOID PREMATURE CLK INT
3923:         SETOM SCHEDF(PID)       ;THIS IS A SCHEDULING INTERRUPT
3924: STOP2:  HLLOS CLKFLG(PID)       ;SET FLAG TO INDICATE CLK INTERRUPT
3925:                                 ;EVEN THOUGH CLK INTERRUPT IS NOT A TIME INTERRUPT
3926:         CONO PI,PION+1B24!1(7-CLKCHN)
3927:                                 ;TURN PI BACK ON AND REQUEST INTERRUPT TO
3928:                                 ;CLK PI CHANNEL(LOWEST PRIORITY CHANNEL)
3929:         POPJ P,                 ;INTERRUPT IMMEDIATELY IF AT UUO LEVEL
    COMCSS page# 0110 next  prev
3931: ;ROUTINE TO WAIT TILL DEVICE CATCHES UP WITH USER AND BECOMES INACTIVE
3932: ;CALLING SEQUENCE
3933: ;     PUSHJ PDP, WAIT1
3934: ;     EXIT        ALWAYS RETURNS HERE
3935:  
3936: ;IF THE DEVICE IS INACTIVE (IOACT=0), RETURNS TO EXIT. OTHERWISE, SETS
3937: ;IOW:=1 AND ENTERS WAIT UNLESS IOACT BECOMES ZERO BEFORE THE
3938: ;JUMP IS MADE, IN WHICH CASE IT SETS IOW:=0 AND RETURNS TO EXIT.
3939: ;ON LEAVING THE WAIT STATE, RETURNS TO EXIT.
3940: ;THIS ROUTINE PREVENTS THE STATE IOACT=0 AND IOW=1 FROM OCCURING
3941: ;CALLING SEQUENCE
3942: ;     PUSHJ PDP, WSYNC
3943: ;     EXIT             ALWAYS RETURNS HERE
3944: ;SETS IOW:=1 AND ENTERS WAIT ROUTINE. RETURNS TO EXIT WHEN IOACT=0.
3945: 
3946: 
3947: WAIT1: MOVE IOS,DEVIOS(DEVDAT)
3948:         MOVE AC1,DEVMOD(DDB)
3949:         TLNE AC1,DVTTY          ;TTY MAY ALWAYS PROCEED FROM HERE!!!!! RPH
3950:         POPJ P,
3951:         TRNN IOS, IOACT         ;IS DEVICE ACTIVE? (IOACT=1?)
3952:         JRST WAIT2
3953:         PUSHJ PDP,WSYNC         ;WAIT
3954:         JRST WAIT1
3955: 
3956: WAIT2:  MOVSI AC1,DEVIBF        ; SET TO CHECK IF THIS DEVICE IS INTERNALLY BUFFERD
3957:         TDNE AC1,DEVCMR(DEVDAT) ; TEST THE BIT
3958:         TLNN IOS,DEVSBB         ; IT HAS A BUFFER, IS IT BUSY?
3959:         POPJ PDP,               ; NO, LEAVE
3960:         PUSHJ PDP,WSYNC         ; YES, WAIT FOR IT
3961:         JRST WAIT1              ; THEN MAKE SURE
    COMCSS page# 0111 next  prev
3963: ;WSYNC IS CALLED TO WAIT UNTIL 
3964: ;SETIOD IS CALLED BY INTERRUPT SERVICE ROUTINE
3965: ;IE  UNTIL CURRENT BUFFER ACTIVITY IS COMPLETED
3966: ;CALLED ONLY FROM UUO LEVEL
3967: ;CALL:  MOVE DEVDAT,ADR. OF DEVICE DATA BLOCK
3968: ;       PUSHJ PDP,WSYNC
3969: ;       RETURN IMMEDIATELY IF DEVICE IS INACTIVE
3970: ;       RETURN WHEN DEVICE FINISHES NEXT BUFFER IF IT IS ACTIVE
3971: 
3972: 
3973: 
3974: WSYNC: MOVSI IOS,IOW           ;SETUP DEVICE IO WAIT BIT
3975:         MOVEI AC1,DIOWQ         ; DISK IO WAIT QUEUE
3976:         MOVE AC3,DEVIOS(DEVDAT) ; SEE IF JOB IS LOCKED IN CORE
3977:         MOVE AC2,DEVMOD(DEVDAT) ; WHICH FOR DEVICES OTHER THAN THE TTY MEANS IOACT IS ON
3978:         TLNN AC2,DVTTY
3979:         TRNN AC3,IOACT          ; LOCKED IN?
3980:         MOVEI AC1,IOWQ          ; NO, STRAIGHT IO WAIT QUEUE CODE
3981:         MOVE AC3,JOB(PID)       ;CURRENT JOB NO.
3982:         HRRZ AC2,DEVCMR(DEVDAT) ; FIRST, DOES HE HAVE CONTROL CELLS?
3983:         SKIPE P2NUM             ; IF P2 IS ACTIVE . . .
3984:         JUMPN AC2,WSYNC1        ; WE CHECK. IF YES, THIS IS A SPECIAL CASE
3985:         MOVSI AC2,DEVIBF        ; ALSO, IS THIS A SCREWEY DEVICE?
3986:         TDNE AC2,DEVCMR(DEVDAT) ; LIKE LPT WITH THE INTERNAL BUFFER
3987:         SKIPA AC2,[XWD DEVSBB,0]
3988:         MOVEI AC2,IOACT
3989:         CONO PI,PIOFF
3990:         TDNN AC2,DEVIOS(DEVDAT)
3991:         JRST WSYNC3
3992:         IORM IOS,DEVIOS(DEVDAT)
3993:         MOVNM AC1,JOBQUE(AC3)
3994:         CONO PI,PION
3995:         PUSHJ PDP,WSCHED
3996:         ANDCAB IOS,DEVIOS(DEVDAT)
3997:         POPJ PDP,
3998: 
3999: WSYNC3: CONO PI,PION
4000:         MOVE IOS,DEVIOS(DEVDAT)
4001:         POPJ PDP,
    COMCSS page# 0112 next  prev
4003: ; WE GET HERE IF THIS DEVICE HAS CONTROL CELLS
4004: ; WE MUST BOTH GET CONTROL OF THE CELLS AND SHUT OFF THE PI
4005: ; BECAUSE EVEN IF P2 IS ACTIVE, THE DEVICE MIGHT NOT BE RUNNING ON P2
4006: 
4007: WSYNC1: MOVSI AC2,DEVIBF        ; NOW SEE IF THIS IS A SCREWEY DEVICE
4008:         TDNE AC2,DEVCMR(DEVDAT)
4009:         SKIPA AC2,[XWD DEVSBB,0]
4010:         MOVEI AC2,IOACT
4011:         PSYNC1 <HRRZ TAC,DEVCMR(DDB)>   ; GET CONTROL OF IOS
4012:         TDNN AC2,DEVIOS(DEVDAT) ; IS THE DEVICE ACTIVE?
4013:         JRST WSYNC2             ; NO, FORGET IT
4014:         CONO PI,PIOFF           ; INTERLOCK OUR FOOLING AROUND
4015:         IORM IOS,DEVIOS(DEVDAT)
4016:         MOVNM AC1,JOBQUE(AC3)
4017:         CONO PI,PION
4018:         XSYNC1 <HRRZ TAC,DEVCMR(DDB)>
4019:         PUSHJ PDP,WSCHED        ; DO THE IO WAITING
4020:         PSYNC1 <HRRZ TAC,DEVCMR(DDB)>
4021:         ANDCAB IOS,DEVIOS(DEVDAT)
4022: WSYNC4: XSYNC1 <HRRZ TAC,DEVCMR(DDB)>
4023:         POPJ P,
4024: 
4025: WSYNC2: MOVE IOS,DEVIOS(DEVDAT) ; RESTORE IOS
4026:         JRST WSYNC4             ; RELEASE CELLS, RESTORE ACS
    COMCSS page# 0113 next  prev
4028: REPEAT 0,<
4029: ; ROUTINE TO SWITCH YOUR JOB TO THE OTHER PROCESSOR TEMPORARILY
4030: ; CALLING . . .
4031: ;       PUSHJ P,PSWITCH
4032: ; CLOBBERS ACCUMULATOR AC1
4033: 
4034: PSWITCH:
4035:         LDB AC1,PRUNB           ; PICK UP THIS JOB'S PROCESSOR BITS
4036:         PUSH P,AC1              ; SAVE THEM
4037:         MOVEI AC1,RUN1
4038:         SKIPN PID
4039:         MOVEI AC1,RUN2
4040:         PSYNC JBTCSC
4041:         DPB AC1,PRUNB
4042:         XSYNC JBTCSC
4043:         PUSHJ P,WSCHED
4044:         MOVE PID,OTHERID(PID)   ; PICK UP THE PROPER ID
4045:         POP P,AC1
4046:         PSYNC JBTCSC
4047:         DPB AC1,PRUNB
4048:         XSYNC JBTCSC            ; RESTORE RUN BITS
4049:         POPJ P,
4050: 
4051: GOTOP1: JUMPE PID,CPOPJ
4052:         JRST PSWITCH
4053: >
 EOF: COMCSS end-of-file. cnt=112